Milimetric has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/323178

Change subject: Implement basic Dashiki extension
......................................................................

Implement basic Dashiki extension

This extension configures the sub-namespace Dashiki in the Config
namespace.  We would like to deploy this on meta so we can create more
valid Dashiki configuration pages as Config:Dashiki:NewDashboardConfig
instead of the current way we're just faking the Config: prefix.  As a
bonus of extending JsonConfig's View and Content, we get nicer display
for our configs and we can start to add useful shortcuts for Dashiki
dashboard maintainers.

Bug: T125403
Change-Id: Ic21c91f43e06f9261d7636ea554702c7242377ee
---
A README
A extension.json
A i18n/en.json
A i18n/ro.json
A includes/DashikiContent.php
A includes/DashikiView.php
6 files changed, 113 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Dashiki 
refs/changes/78/323178/1

diff --git a/README b/README
new file mode 100644
index 0000000..d26310f
--- /dev/null
+++ b/README
@@ -0,0 +1,15 @@
+This is a mediawiki extension that configures the Dashiki sub-namespace to the 
Config namespace.  It makes Dashiki configurations easier to read and provides 
convenient functionality to work with Dashiki dashboards.  For now, it's 
bare-bones.
+
+Install
+=======
+
+To install, add the following to LocalSettings.php
+
+    // Configure Dashiki sub-namespace with JsonConfig
+    $wgJsonConfigs['JsonConfig.Dashiki'] = array(
+      'pattern' => '/^Dashiki\:./',
+      'isLocal' => true,
+    );
+
+    // register the custom model and view implemented by the Dashiki extension
+    $wgJsonConfigModels['JsonConfig.Dashiki'] = 'Dashiki\DashikiContent';
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..b793788
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,21 @@
+{
+    "name": "Dashiki",
+    "version": "0.1.0",
+    "author": [
+        "Dan Andreescu"
+    ],
+    "url": "https://www.mediawiki.org/wiki/Extension:Dashiki";,
+    "descriptionmsg": "dashiki-desc",
+    "type": "other",
+    "license-name": "GPL-2.0+",
+    "MessagesDirs": {
+        "Dashiki": [
+            "i18n"
+        ]
+    },
+    "AutoloadClasses": {
+        "Dashiki\\DashikiContent": "includes/DashikiContent.php",
+        "Dashiki\\DashikiView": "includes/DashikiView.php"
+    },
+    "manifest_version": 2
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..ded80a4
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,3 @@
+{
+    "dashiki-desc": "Dashiki is a dashboarding tool that uses wiki pages as 
configuration.  This extension helps Dashiki authors read and edit valid 
configuration pages on wiki."
+}
diff --git a/i18n/ro.json b/i18n/ro.json
new file mode 100644
index 0000000..2cf3558
--- /dev/null
+++ b/i18n/ro.json
@@ -0,0 +1,3 @@
+{
+    "dashiki-desc": "Dashiki construieşte dashboard-uri din configuraţii 
salvate pe un wiki.  Extensia asta ajută autorul Dashiki să citească şi să 
creeze configuraţii valide pe wiki."
+}
diff --git a/includes/DashikiContent.php b/includes/DashikiContent.php
new file mode 100644
index 0000000..d2ed4e6
--- /dev/null
+++ b/includes/DashikiContent.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Dashiki;
+
+use JsonConfig\JCContent;
+
+/**
+ * Custom Dashiki validation goes here, currently just defaults to 
JsonConfig\JCContent
+ * @file
+ * @ingroup Extensions
+ * @ingroup Dashiki
+ *
+ * @author Dan Andreescu
+ */
+class DashikiContent extends JCContent {
+
+    protected function createDefaultView() {
+        return new DashikiView();
+    }
+}
diff --git a/includes/DashikiView.php b/includes/DashikiView.php
new file mode 100644
index 0000000..d693c44
--- /dev/null
+++ b/includes/DashikiView.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Dashiki;
+
+use JsonConfig\JCContent;
+use JsonConfig\JCDefaultContentView;
+use FormatJson;
+use Html;
+use ParserOptions;
+use ParserOutput;
+use Title;
+
+/**
+ * Used to render Dashiki JSON configuration pages to HTML
+ * @package Dashiki
+ */
+class DashikiView extends JCDefaultContentView {
+
+    /**
+     * Returns an empty Dashiki configuration
+     * @param string $modelId
+     * @return string
+     */
+    public function getDefault( $modelId ) {
+        return "{\n}";
+    }
+
+    /**
+     * Customizes valueToHtml() for Dashiki
+     *
+     * @param JCContent $content
+     * @param Title $title Context title for parsing
+     * @param int|null $revId Revision ID (for {{REVISIONID}})
+     * @param ParserOptions $options Parser options
+     * @param bool $generateHtml Whether or not to generate HTML
+     * @param ParserOutput &$output The output object to fill (reference).
+     * @return string
+     */
+    public function valueToHtml(
+        JCContent $content, Title $title, $revId, ParserOptions $options, 
$generateHtml,
+         ParserOutput &$output
+    ) {
+        $header = $this->renderHeader( $title->getText() );
+        $tableDisplay = $this->renderValue( $content, $content->getData(), [] 
);
+        return $header . $tableDisplay;
+    }
+
+    public function renderHeader( $title ) {
+        return "<span>Build a dashboard with this config using: 
</span><pre>gulp --config " . $title ." --layout /*...*/</pre>";
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/323178
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic21c91f43e06f9261d7636ea554702c7242377ee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Dashiki
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to