Jump to content

User:Katie Horn/notes/Amsterdam2013

From Wikitech

http://www.mediawiki.org/wiki/Amsterdam_Hackathon_2013

I think I probably want to learn more about Scribunto, or Wikidata. Happily, wikidata depends on Scribunto, so it looks like I do option #1 either way.

Whatever I find out, I'd like to use sneakily on donatewiki.

Friday

Pretty sure I want to learn the new wave of on-wiki templating.

Install Things

Scribunto

Scribunto

  1. WikiEditor
  2. Syntax... thingy
  3. CodeEditor
  4. sudo apt-get install lua5.1 (Not optimal, but ostensibly faster to get going initially)
  5. dpkg -L lua5.1 (to figure out WhereTF it landed)
  6. $wgScribuntoEngineConf['luastandalone']['luaPath'] = '[answer from the last thing]'; (in LocalSettings)

Problems

Splat

And then the whole thing goes splat. And by "splat" I mean this happens when I try to save a module on my local dev wiki:

Fatal error: Call to undefined method MWNamespace::getNamespaceContentModel() in /srv/mw_extensions/Scribunto/engines/LuaCommon/SiteLibrary.php on line 41 

Additionally, with SyntaxHighlight_GeSHi enabled, this happens constantly:

Notice: Use of undefined constant CONTENT_MODEL_CSS - assumed 'CONTENT_MODEL_CSS' in /srv/mw_extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php on line 75 
Notice: Use of undefined constant CONTENT_MODEL_JAVASCRIPT - assumed 'CONTENT_MODEL_JAVASCRIPT' in /srv/mw_extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php on line 76

The particular reason it goes splat, seems to be that some content model thing doesn't exist on the fundraising branch of core (last branched from 1.22-something, supposedly).

In fact, getNamespaceContentModel() called straight from Scribunto doesn't exist in 1.20.

khorn@eddie:/srv/mw_core2$ git diff remotes/gerrit/wmf/1.21wmf6..remotes/gerrit/wmf/1.21wmf9 includes/Namespace.php
diff --git a/includes/Namespace.php b/includes/Namespace.php
index e8d5632..46af002 100644
--- a/includes/Namespace.php
+++ b/includes/Namespace.php
@@ -419,4 +419,18 @@ class MWNamespace {
                return $wgNonincludableNamespaces && in_array( $index, $wgNonincludableNamespaces );
        }
 
+       /**
+        * Get the default content model for a namespace
+        * This does not mean that all pages in that namespace have the model
+        *
+        * @since 1.21
+        * @param $index int Index to check
+        * @return null|string default model name for the given namespace, if set
+        */
+       public static function getNamespaceContentModel( $index ) {
+               global $wgNamespaceContentModels;
+               return isset( $wgNamespaceContentModels[$index] )
+                       ? $wgNamespaceContentModels[$index]
+                       : null;
+       }
 }

This seems to conflict deeply with the assertion on the Scribunto page that the extension is compatible with 1.20 and beyond.

...I'm sure it was at one point.

Splat Resolution

Download the latest version of core and use that.

This requires a schema update for things that are also related to the content model. Enjoyably, after the update, php5 crashed twice and asked if I would like to submit my error experience to ubuntu.

Wikibase (wikidata software)

Wikibase Client (wikidata)

Lua session notes

  • TemplateSandbox - Holy cow. With this, we can preview pages as they would render after a pending template change, without saving. Neat!
  • frame:getParent - gets the frame from the template invoking the module. Probably awesome for... rabbit-holing. Danger. But... probably cool danger.

Friday Night Recalibration

  • Siebrand has pointed out that my thin excuse for learning Scribunto/lua is faulty, and that I should just add everything I want to know about currencies to the CLDR extension. He's probably right.
    • That would involve pulling and parsing data from here and here, and telling them when they're outright wrong instead of just changing it on our end.
      ...for instance, the symbol for JPY in ja. Fail. I went there. Many Japanese people told me personally in focus groups, to use 円 and not ¥. But, in the interest of getting 90% there, it's probably a Good Idea.
  • I still want to use Scribunto/lua on donate wiki. We're driving the poor production folks crazy.
  • Semantic Mediawiki for overall donation pipeline settings? Hmmmm...

Saturday

CLDR seems like an excellent idea to work on. I aim to be able to add code to the thing that builds other things, to build also these things:

Decimal Digits and Rounding (currencies)

TODO:

  • Parse out the data into a readable array in a file
  • Write a static function to get the data in that file
common/supplemental/supplementalData.xml :
<supplementalData>
  <currencyData>
    <fractions>
      <info iso4217="ADP" digits="0" rounding="0"/>
      <info iso4217="BHD" digits="3" rounding="0"/>
      <info iso4217="BIF" digits="0" rounding="0"/>
      <info iso4217="CAD" digits="2" rounding="0" cashRounding="5"/>
      <info iso4217="DEFAULT" digits="2" rounding="0"/>

Code Lists: Currencies

TODO:

  • Parse the xml and generate the symbol array
  • Write the function to get the symbol for a particular country
/common/main/[language].xml
<ldml>
  <identity>
    <version number="$Revision: 8257 $"/>
    <generation date="$Date: 2013-02-26 20:38:03 -0800 (Tue, 26 Feb 2013) $"/>
    <language type="ja"/>
  </identity>
  <numbers>
    <currencies>
      <currency type="EUR">
        <displayName>ユーロ</displayName>
        <symbol>€</symbol>
      </currency>
      <currency type="JPY">
        <displayName>日本円</displayName>
        <symbol>¥</symbol>
      </currency>

Currency Formatting

Hey: What's this bit?

/common/main/[language].xml
<ldml>
  <identity>
    <version number="$Revision: 8257 $"/>
    <generation date="$Date: 2013-02-26 20:38:03 -0800 (Tue, 26 Feb 2013) $"/>
    <language type="ja"/>
  </identity>
  <numbers>
    <currencyFormats numberSystem="latn">
      <currencyFormatLength>
        <currencyFormat>
          <pattern>¤#,##0.00</pattern>
        </currencyFormat>
      </currencyFormatLength>
      <unitPattern count="other">{0} {1}</unitPattern>
    </currencyFormats>

Region to Currency lists

TODO:

  • parse out XML
  • Write sensible get function
common/supplemental/supplementalData.xml :
<supplementalData>
  <currencyData>
    <region iso3166="HT">
      <currency iso4217="HTG" from="1872-08-26"/>
      <currency iso4217="USD" from="1915"/>
    </region>
    <region iso3166="IE">
      <currency iso4217="EUR" from="1999-01-01"/>
      <currency iso4217="IEP" from="1922-01-01" to="2002-02-09"/>
      <currency iso4217="GBP" from="1800-01-01" to="1922-01-01"/>
    </region>

Sunday

https://gerrit.wikimedia.org/r/#/c/65608/