Welterkj has uploaded a new change for review.
https://gerrit.wikimedia.org/r/188686
Change subject: Make category pages less obtrusive.
......................................................................
Make category pages less obtrusive.
Make the category pages created by this extension optional,
non-empty and do not tag “dummy” images as belonging to a category.
Change-Id: I9ba117c7844cd1d43150e6fbfabc837f0596faa6
---
M GraphViz.php
M GraphViz_body.php
M RELEASE-NOTES.md
3 files changed, 47 insertions(+), 35 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GraphViz
refs/changes/86/188686/1
diff --git a/GraphViz.php b/GraphViz.php
index 3ac07c2..0b9ca20 100644
--- a/GraphViz.php
+++ b/GraphViz.php
@@ -33,7 +33,7 @@
if ( !defined( 'MEDIAWIKI' ) ) die();
-define( 'GraphViz_VERSION', '1.5.1' );
+define( 'GraphViz_VERSION', '1.6.0' );
/**
* The GraphViz settings class.
@@ -67,23 +67,36 @@
* @var string $defaultImageType
*/
public $defaultImageType;
+
+ /**
+ * Whether or not to automatically create category pages for images
created by this extension.
+ * yes|no (case insensitive). The default is no.
+ *
+ * @var string $createCategoryPages
+ */
+ public $createCategoryPages;
+
+ /**
+ * Constructor for setting configuration variable defaults.
+ */
+ public function __construct() {
+ // Set execution path
+ if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'Darwin' ) )
{
+ $this->execPath = 'C:/Program Files/Graphviz/bin/';
+ } else {
+ $this->execPath = '/usr/bin/';
+ }
+
+ $this->mscgenPath = '';
+ $this->defaultImageType = 'png';
+ $this->createCategoryPages = 'no';
+ }
};
$GLOBALS['wgGraphVizSettings'] = new GraphVizSettings();
//self executing anonymous function to prevent global scope assumptions
call_user_func( function() {
-
- // Set execution path
- if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'Darwin' ) ) {
- $GLOBALS['wgGraphVizSettings']->execPath = 'C:/Program
Files/Graphviz/bin/';
- } else {
- $GLOBALS['wgGraphVizSettings']->execPath = '/usr/bin/';
- }
-
- $GLOBALS['wgGraphVizSettings']->mscgenPath = '';
- $GLOBALS['wgGraphVizSettings']->defaultImageType = 'png';
-
$dir = __DIR__ . '/';
$GLOBALS['wgMessagesDirs']['GraphViz'] = $dir . 'i18n';
diff --git a/GraphViz_body.php b/GraphViz_body.php
index f871270..cf091b4 100644
--- a/GraphViz_body.php
+++ b/GraphViz_body.php
@@ -130,20 +130,6 @@
const ROOT_CATEGORY = "GraphViz";
/**
- * Subcategories of pages created by this extension.
- * @var array $subCategories
- */
- private static $subCategories = array(
- 'mscgen',
- 'dot',
- 'neato',
- 'fdp',
- 'sfdp',
- 'circo',
- 'twopi'
- );
-
- /**
* A list of dot attributes that are forbidden.
* @see http://www.graphviz.org/content/attrs#dimagepath
* @see http://www.graphviz.org/content/attrs#dshapefile
@@ -335,15 +321,18 @@
}
/**
- * Create a category page for GraphViz::ROOT_CATEGORY and subcategory
pages for GraphViz::$subCategories.
+ * Optionally create a category page for GraphViz::ROOT_CATEGORY and
the given subcategory.
+ * @param[in] string $subCategory is the same as the graph renderer.
* @author Keith Welter
*/
- public static function createCategoryPages() {
- $rootCategoryName = self::ROOT_CATEGORY;
- $rootCategoryDesc = wfMessage( 'graphviz-category-desc',
"[[:Category:$rootCategoryName]]" )->text();
- self::createCategoryPage( $rootCategoryName, $rootCategoryDesc,
"" );
+ public static function optionallyCreateCategoryPage( $subCategory ) {
+ global $wgGraphVizSettings;
- foreach( self::$subCategories as $subCategory ) {
+ if ( strcasecmp( $wgGraphVizSettings->createCategoryPages,
'yes' ) == 0 ) {
+ $rootCategoryName = self::ROOT_CATEGORY;
+ $rootCategoryDesc = wfMessage(
'graphviz-category-desc', "[[:Category:$rootCategoryName]]" )->text();
+ self::createCategoryPage( $rootCategoryName,
$rootCategoryDesc, "" );
+
$subCategoryName = $rootCategoryName . ' ' .
$subCategory;
$subCategoryDesc = wfMessage(
'graphviz-subcategory-desc', "[[:Category:$subCategoryName]]", $subCategory
)->text();
$subCategoryDesc .= "[[Category:$rootCategoryName]]";
@@ -411,8 +400,6 @@
* @return true
*/
public static function onParserInit( Parser &$parser ) {
- self::createCategoryPages();
-
foreach ( self::$graphTypes as $graphType ) {
$parser->setHook( self::$tags[$graphType] , array(
__CLASS__, self::$parserHookFunctions[$graphType] ) );
}
@@ -567,6 +554,8 @@
} else {
wfDebug( __METHOD__ . ": uploaded
$imageFilePath\n" );
$uploaded++;
+
+ self::optionallyCreateCategoryPage(
$renderer );
}
} else {
// The upload for this title has already
occured in GraphViz::render
@@ -580,6 +569,8 @@
// Go ahead and count this as an upload since
it has been done.
$uploaded++;
+
+ self::optionallyCreateCategoryPage( $renderer );
}
}
wfDebug( __METHOD__ . ": uploaded $uploaded files for article:
$titleText\n" );
@@ -1173,7 +1164,12 @@
}
// prepare to upload
- $pageText = self::getCategoryTags( $renderer );
+ $pageText = "";
+
+ // don't bother tagging dummies
+ if ( !$isDummy ) {
+ $pageText = self::getCategoryTags( $renderer );
+ }
$comment = wfMessage( 'graphviz-upload-comment',
$titleText )->text();
$watch = false;
$removeTempFile = true;
diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index b316580..83cb2b5 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -1,5 +1,8 @@
These are the release notes for the [MediaWiki][mediawiki] [GraphViz
extension][gv_ext].
+## GraphViz 1.6.0 ## (not released yet )
+* Make the category pages created by this extension optional, non-empty and do
not tag “dummy” images as belonging to a category.
+
## GraphViz 1.5.1 ## (2015-1-24)
* Fix for [bug T75073](https://phabricator.wikimedia.org/T75073).
--
To view, visit https://gerrit.wikimedia.org/r/188686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ba117c7844cd1d43150e6fbfabc837f0596faa6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GraphViz
Gerrit-Branch: master
Gerrit-Owner: Welterkj <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits