Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Publishing a code sample book from Stackoverflow to LeanPub using Drupal and GitLab

Parent Feed: 

We built a developer portal for iText that helps them to republish questions, answers, and code samples from Stackoverflow in their documentation. The same Drupal site also has an export function that packages the markdown content from the questions in a format that can be published on LeanPub, where it becomes available as a PDF, EPUB or MOBI document.

Stackoverflow is a great content marketing channel for developer evangelists. iText, the company that created the eponymous PDF library, has used Stackoverflow with great success to gain a strong reputation with developers and to build a sustainable business around their open source software.

In this blogpost we want to share how Bruno Lowagie (the original developer of iText) designed a workflow that allows him to publish questions and answers from Stackoverflow on the iText Drupal site and then export them to LeanPub (utilizing a custom Drupal module):

  1. A user posts a question on Stackoverflow, such as “Can’t get Czech characters while generating a PDF”:

  1. To answer this question, we create a standalone example.The finished sample code is then uploaded to GitLab, the open source code repository that iText uses to manage their project’s source code and example files.
  1. Then - when publishing the example Java file into the Examples section of the iText developers website (as a book node) - we use a custom Drupal module to link to the sample code file in GitLab and display the contents of that file within the node.

  1. Having all the elements in place, we answer the question in Stackoverflow - referring to the example with some information and a link to the source code and the resulting PDFs.
  1. Afterwards, we post the example - containing the code written when answering the Stackoverflow question - into the Q&A section of the iText developers website.

  1. In addition to the content now being accessible through the Q&A and Examples sections of the iText developers website (as well as in the original Stackoverflow post), we are also able to export the structured book content into the format (a ZIP file) required for publishing on LeanPub - utilizing a custom Drupal module developed to handle the Leanpub-specific format: Contents of LeanPub-specific book export from Drupal:

  1. Next, we are able to take the LeanPub-specific contents of the exported Drupal book and publish them on LeanPub:


See also Bruno Lowagie's video tutorial:

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web