Volunteer:Development/DabbleDB integration

From Gospel Translations

(Difference between revisions)
Jump to:navigation, search
(New page: 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. ...)
 
(2 intermediate revisions not shown)
Line 1: Line 1:
 +
__NOTOC__
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.  
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===
 
-
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.
+
==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.
-
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:
+
====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<br>Resource: 10 Reasons Why I Am Thankful for the God-Breathed Bible<br>Resource » Book/series: Taste and See<br>Resource » Author: John Piper<br>Resource » Second Author: None<br>Resource » Publisher: Desiring God<br>Resource » Topic: Spiritual Growth<br>Resource » Subtopic: The Bible<br>Resource » Media Type: Article<br>Resource » Date: November 20, 2006<br>Resource » Sort Order: 0<br>Translator: Zo Tin Khuma<br>Language: Burmese<br>Review Status: Not Reviewed<br>
::10 Reasons Why I Am Thankful for the God-Breathed Bible<br>Resource: 10 Reasons Why I Am Thankful for the God-Breathed Bible<br>Resource » Book/series: Taste and See<br>Resource » Author: John Piper<br>Resource » Second Author: None<br>Resource » Publisher: Desiring God<br>Resource » Topic: Spiritual Growth<br>Resource » Subtopic: The Bible<br>Resource » Media Type: Article<br>Resource » Date: November 20, 2006<br>Resource » Sort Order: 0<br>Translator: Zo Tin Khuma<br>Language: Burmese<br>Review Status: Not Reviewed<br>
-
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 <code>serialize</code> function, in this format:
+
====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 <code>serialize</code> function, in this format:
:<code>$db[ Language ][ Article Title ][ attribute ] => value</code>
:<code>$db[ Language ][ Article Title ][ attribute ] => value</code>
For instance
For instance
:<code>$db['Spanish']['Gospel Implications']['Publisher'] => "Ligonier Ministries"</code>
:<code>$db['Spanish']['Gospel Implications']['Publisher'] => "Ligonier Ministries"</code>
-
3. Meanwhile, every article or book on our wiki calls a [http://www.mediawiki.org/wiki/Help:Templates template], <code>[[Template:Info|<nowiki>{{Info}}</nowiki>]]</code>. The <code><nowiki>{{Info}}</nowiki></code> template figures out the language (<code>$resLang</code>) and title (<code>$res</code>) of the article and runs our custom [http://www.mediawiki.org/wiki/Manual:Parser_functions parser function], <code><nowiki>{{#ib:}}</nowiki></code>. So this call
+
Here is a portion of the output from <code>print_r($db)</code>
 +
<pre>
 +
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
 +
                )
 +
 
 +
        )
 +
)
 +
</pre>
 +
 
 +
====Step 3====
 +
Meanwhile, every article or book on our wiki calls a [http://www.mediawiki.org/wiki/Help:Templates template], <code>[[Template:Info|<nowiki>{{Info}}</nowiki>]]</code>. The <code><nowiki>{{Info}}</nowiki></code> template figures out the language (<code>$resLang</code>) and title (<code>$res</code>) of the article and runs our custom [http://www.mediawiki.org/wiki/Manual:Parser_functions parser function], <code><nowiki>{{#ib:}}</nowiki></code>. So this call
::<code>$db[ $resLang ][ $res ]['Publisher']</code>
::<code>$db[ $resLang ][ $res ]['Publisher']</code>
will return the publisher of the given article.
will return the publisher of the given article.
-
4. <code><nowiki>{{#ib:}}</nowiki></code> tries to find <code>$db[ $resLang ][ $res ]</code>, and if successful it returns the code for the "About this Resource" box (including several <code><nowiki>[[Category:xx]]</nowiki></code> tags to help the wiki sort its content).
+
====Step 4====
 +
<code><nowiki>{{#ib:}}</nowiki></code> tries to find <code>$db[ $resLang ][ $res ]</code>, and if successful it returns the code for the "About this Resource" box (including several <code><nowiki>[[Category:xx]]</nowiki></code> tags to help the wiki sort its content).
...and that is how the info automation with DabbleDB works.
...and that is how the info automation with DabbleDB works.
 +
 +
[[Category:Tech admin]]

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