Volunteer:Development/DabbleDB integration

From Gospel Translations

(Difference between revisions)
Jump to:navigation, search
 

Current revision as of 19:06, 17 December 2009

In order for Gospel Translations to stay well organized with minimal load on volunteers, we needed to find a way to automate the insertion of the "About this Resource" box into articles.


How it works

Step 0

All of our article information and activity records are stored in an online database at DabbleDB, which produces real-time data exports for us upon request.

Step 1

A cronjob runs every 5 minutes on our web server to import the most up-to-date information from DabbleDB. It arrives in text format like this:

10 Reasons Why I Am Thankful for the God-Breathed Bible
Resource: 10 Reasons Why I Am Thankful for the God-Breathed Bible
Resource » Book/series: Taste and See
Resource » Author: John Piper
Resource » Second Author: None
Resource » Publisher: Desiring God
Resource » Topic: Spiritual Growth
Resource » Subtopic: The Bible
Resource » Media Type: Article
Resource » Date: November 20, 2006
Resource » Sort Order: 0
Translator: Zo Tin Khuma
Language: Burmese
Review Status: Not Reviewed

Step 2

When the data is imported, it gets pushed through a PHP script that breaks it into a multidimensional array and saves it to a flat file using PHP's serialize function, in this format:

$db[ Language ][ Article Title ][ attribute ] => value

For instance

$db['Spanish']['Gospel Implications']['Publisher'] => "Ligonier Ministries"

Here is a portion of the output from print_r($db)

Array
(
    [Burmese] => Array
        (
            [10 Reasons Why I Am Thankful for the God-Breathed Bible] => Array
                (
                    [Name] => 10 Reasons Why I Am Thankful for the God-Breathed Bible
                    [Book/series] => Taste and See
                    [Author] => John Piper
                    [Second Author] => None
                    [Publisher] => Desiring God
                    [Topic] => Spiritual Growth
                    [Subtopic] => The Bible
                    [Media Type] => Article
                    [Date] => November 20, 2006
                    [Sort Order] => 0
                    [Translator] => Zo Tin Khuma
                    [Language] => Burmese
                    [Review Status] => Not Reviewed
                    [Reviewer] => None
                )

            [Gospel Implications] => Array
                (
                    [Name] => Gospel Implications
                    [Book/series] => Article
                    [Author] => Mike Bullmore
                    [Second Author] => None
                    [Publisher] => 9Marks
                    [Topic] => Church Leadership
                    [Subtopic] => Pastoral Ministry
                    [Media Type] => Article
                    [Date] => September 19, 2007
                    [Sort Order] => 0
                    [Translator] => Hrang Hmung
                    [Language] => Burmese
                    [Review Status] => Not Reviewed
                    [Reviewer] => None
                )

        )
)

Step 3

Meanwhile, every article or book on our wiki calls a template, {{Info}}. The {{Info}} template figures out the language ($resLang) and title ($res) of the article and runs our custom parser function, {{#ib:}}. So this call

$db[ $resLang ][ $res ]['Publisher']

will return the publisher of the given article.

Step 4

{{#ib:}} tries to find $db[ $resLang ][ $res ], and if successful it returns the code for the "About this Resource" box (including several [[Category:xx]] tags to help the wiki sort its content).

...and that is how the info automation with DabbleDB works.

Navigation
Volunteer Tools
Other Wikis
Toolbox