From d7bb13ca855839084de7527c5ccc66b317489d75 Mon Sep 17 00:00:00 2001 From: Matthieu Aubry Date: Thu, 22 Sep 2016 21:47:00 +1200 Subject: Renamed plugin ExampleRssWidget -> RssWidget (#10528) * Renamed plugin ExampleRssWidget -> RssWidget * Activate file on upgrade to 3.0.0-b1 * Fix system test --- config/environment/ui-test.php | 2 +- config/global.ini.php | 2 +- core/Updates/3.0.0-b1.php | 6 ++ plugins/Dashboard/Dashboard.php | 2 +- plugins/ExampleRssWidget/ExampleRssWidget.php | 30 -------- plugins/ExampleRssWidget/RssRenderer.php | 84 ---------------------- plugins/ExampleRssWidget/Widgets/RssChangelog.php | 49 ------------- plugins/ExampleRssWidget/Widgets/RssPiwik.php | 47 ------------ plugins/ExampleRssWidget/plugin.json | 15 ---- plugins/ExampleRssWidget/stylesheets/rss.less | 33 --------- plugins/RssWidget/RssRenderer.php | 84 ++++++++++++++++++++++ plugins/RssWidget/RssWidget.php | 38 ++++++++++ plugins/RssWidget/Widgets/RssChangelog.php | 49 +++++++++++++ plugins/RssWidget/Widgets/RssPiwik.php | 47 ++++++++++++ plugins/RssWidget/plugin.json | 15 ++++ plugins/RssWidget/stylesheets/rss.less | 33 +++++++++ plugins/Widgetize/tests/System/WidgetTest.php | 16 ++--- ...apiGetReportMetadata__API.getWidgetMetadata.xml | 12 ++-- ...etReportMetadata__API.getWidgetMetadata_day.xml | 12 ++-- tests/resources/screenshot-override/override.css | 2 +- 20 files changed, 296 insertions(+), 282 deletions(-) delete mode 100644 plugins/ExampleRssWidget/ExampleRssWidget.php delete mode 100644 plugins/ExampleRssWidget/RssRenderer.php delete mode 100644 plugins/ExampleRssWidget/Widgets/RssChangelog.php delete mode 100644 plugins/ExampleRssWidget/Widgets/RssPiwik.php delete mode 100644 plugins/ExampleRssWidget/plugin.json delete mode 100644 plugins/ExampleRssWidget/stylesheets/rss.less create mode 100644 plugins/RssWidget/RssRenderer.php create mode 100644 plugins/RssWidget/RssWidget.php create mode 100644 plugins/RssWidget/Widgets/RssChangelog.php create mode 100644 plugins/RssWidget/Widgets/RssPiwik.php create mode 100644 plugins/RssWidget/plugin.json create mode 100644 plugins/RssWidget/stylesheets/rss.less diff --git a/config/environment/ui-test.php b/config/environment/ui-test.php index b5ef0fede4..6d9235ed21 100644 --- a/config/environment/ui-test.php +++ b/config/environment/ui-test.php @@ -54,7 +54,7 @@ return array( $result = str_replace(realpath(PIWIK_INCLUDE_PATH), '', $result); }), - array('Controller.ExampleRssWidget.rssPiwik.end', function (&$result, $parameters) { + array('Controller.RssWidget.rssPiwik.end', function (&$result, $parameters) { $result = ""; }), )), diff --git a/config/global.ini.php b/config/global.ini.php index 1cdf1cb302..61f5045a63 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -777,7 +777,7 @@ Plugins[] = VisitFrequency Plugins[] = VisitTime Plugins[] = VisitorInterest Plugins[] = ExampleAPI -Plugins[] = ExampleRssWidget +Plugins[] = RssWidget Plugins[] = Feedback Plugins[] = Monolog diff --git a/core/Updates/3.0.0-b1.php b/core/Updates/3.0.0-b1.php index 9fe4e11d40..6d3a61ad65 100644 --- a/core/Updates/3.0.0-b1.php +++ b/core/Updates/3.0.0-b1.php @@ -66,6 +66,12 @@ class Updates_3_0_0_b1 extends Updates // added .woff and woff2 whitelisted file for apache webserver ServerFilesGenerator::deleteHtAccessFiles(); ServerFilesGenerator::createHtAccessFiles(); + + // Renamed plugin ExampleRssWidget -> RssWidget + try { + \Piwik\Plugin\Manager::getInstance()->activatePlugin('RssWidget'); + } catch (\Exception $e) { + } } private function migratePluginEmailUpdateSetting() diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index 56f65e8fb9..e2ded0aa2b 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -165,7 +165,7 @@ class Dashboard extends \Piwik\Plugin {"uniqueId":"widgetUserCountryMapvisitorMap","parameters":{"module":"UserCountryMap","action":"visitorMap"}}, {"uniqueId":"widgetDevicesDetectiongetBrowsers","parameters":{"module":"DevicesDetection","action":"getBrowsers"}}, {"uniqueId":"widgetReferrersgetSearchEngines","parameters":{"module":"Referrers","action":"getSearchEngines"}}, - {"uniqueId":"widgetExampleRssWidgetrssPiwik","parameters":{"module":"ExampleRssWidget","action":"rssPiwik"}} + {"uniqueId":"widgetRssWidgetrssPiwik","parameters":{"module":"RssWidget","action":"rssPiwik"}} ] ]'; } diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php deleted file mode 100644 index 3fd348f80d..0000000000 --- a/plugins/ExampleRssWidget/ExampleRssWidget.php +++ /dev/null @@ -1,30 +0,0 @@ - 'getStylesheetFiles' - ); - } - - public function getStylesheetFiles(&$stylesheets) - { - $stylesheets[] = "plugins/ExampleRssWidget/stylesheets/rss.less"; - } -} diff --git a/plugins/ExampleRssWidget/RssRenderer.php b/plugins/ExampleRssWidget/RssRenderer.php deleted file mode 100644 index 7990b1acb8..0000000000 --- a/plugins/ExampleRssWidget/RssRenderer.php +++ /dev/null @@ -1,84 +0,0 @@ -url = $url; - } - - public function showDescription($bool) - { - $this->showDescription = $bool; - } - - public function showContent($bool) - { - $this->showContent = $bool; - } - - public function setCountPosts($count) - { - $this->count = $count; - } - - public function get() - { - try { - $content = Http::fetchRemoteFile($this->url); - $rss = simplexml_load_string($content); - } catch (\Exception $e) { - echo "Error while importing feed: {$e->getMessage()}\n"; - exit; - } - - $output = '
'; - return $output; - } -} diff --git a/plugins/ExampleRssWidget/Widgets/RssChangelog.php b/plugins/ExampleRssWidget/Widgets/RssChangelog.php deleted file mode 100644 index d42737b3fa..0000000000 --- a/plugins/ExampleRssWidget/Widgets/RssChangelog.php +++ /dev/null @@ -1,49 +0,0 @@ -setCategoryId('About Piwik'); - $config->setName('Piwik Changelog'); - } - - public function render() - { - try { - $rss = new RssRenderer('http://feeds.feedburner.com/PiwikReleases'); - $rss->setCountPosts(1); - $rss->showDescription(true); - $rss->showContent(false); - - return $rss->get(); - - } catch (\Exception $e) { - - return $this->error($e); - } - } - - /** - * @param \Exception $e - * @return string - */ - private function error($e) - { - return '
' - . Piwik::translate('General_ErrorRequest', array('', '')) - . ' - ' . $e->getMessage() . '
'; - } -} diff --git a/plugins/ExampleRssWidget/Widgets/RssPiwik.php b/plugins/ExampleRssWidget/Widgets/RssPiwik.php deleted file mode 100644 index 489b703656..0000000000 --- a/plugins/ExampleRssWidget/Widgets/RssPiwik.php +++ /dev/null @@ -1,47 +0,0 @@ -setCategoryId('About Piwik'); - $config->setName('Piwik.org Blog'); - } - - public function render() - { - try { - $rss = new RssRenderer('http://feeds.feedburner.com/Piwik'); - $rss->showDescription(true); - - return $rss->get(); - - } catch (\Exception $e) { - - return $this->error($e); - } - } - - /** - * @param \Exception $e - * @return string - */ - private function error($e) - { - return '
' - . Piwik::translate('General_ErrorRequest', array('', '')) - . ' - ' . $e->getMessage() . '
'; - } -} diff --git a/plugins/ExampleRssWidget/plugin.json b/plugins/ExampleRssWidget/plugin.json deleted file mode 100644 index 6775022287..0000000000 --- a/plugins/ExampleRssWidget/plugin.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "ExampleRssWidget", - "description": "Piwik Platform showcase: how to create a new widget that displays a user submitted RSS feed.", - "version": "1.0", - "keywords": ["example", "feed", "widget"], - "homepage": "http://piwik.org", - "license": "GPL v3+", - "authors": [ - { - "name": "Piwik", - "email": "hello@piwik.org", - "homepage": "http://piwik.org" - } - ] -} \ No newline at end of file diff --git a/plugins/ExampleRssWidget/stylesheets/rss.less b/plugins/ExampleRssWidget/stylesheets/rss.less deleted file mode 100644 index 11f4d9dbbe..0000000000 --- a/plugins/ExampleRssWidget/stylesheets/rss.less +++ /dev/null @@ -1,33 +0,0 @@ -.rss ul { - list-style: none outside none; - padding: 0; -} - -.rss li { - line-height: 140%; - margin: 0.5em 0 1em; -} - -.rss-title, .rss-date { - float: left; - font-size: 14px; - line-height: 140%; -} - -.rss-title { - color: #2583AD; - margin: 0 0.5em 0.2em 0; - font-weight: bold; -} - -.rss-date { - color: #999999; - margin: 0; -} - -.rss-content, .rss-description { - clear: both; - line-height: 1.5em; - font-size: 13px; - color: #333333; -} diff --git a/plugins/RssWidget/RssRenderer.php b/plugins/RssWidget/RssRenderer.php new file mode 100644 index 0000000000..51c831cd4c --- /dev/null +++ b/plugins/RssWidget/RssRenderer.php @@ -0,0 +1,84 @@ +url = $url; + } + + public function showDescription($bool) + { + $this->showDescription = $bool; + } + + public function showContent($bool) + { + $this->showContent = $bool; + } + + public function setCountPosts($count) + { + $this->count = $count; + } + + public function get() + { + try { + $content = Http::fetchRemoteFile($this->url); + $rss = simplexml_load_string($content); + } catch (\Exception $e) { + echo "Error while importing feed: {$e->getMessage()}\n"; + exit; + } + + $output = '
'; + return $output; + } +} diff --git a/plugins/RssWidget/RssWidget.php b/plugins/RssWidget/RssWidget.php new file mode 100644 index 0000000000..03f2af97d9 --- /dev/null +++ b/plugins/RssWidget/RssWidget.php @@ -0,0 +1,38 @@ + 'getStylesheetFiles', + 'Request.getRenamedModuleAndAction' => 'renameExampleRssWidgetModule', + ); + } + + public function getStylesheetFiles(&$stylesheets) + { + $stylesheets[] = "plugins/RssWidget/stylesheets/rss.less"; + } + + public function renameExampleRssWidgetModule(&$module, &$action) + { + if ($module == 'ExampleRssWidget') { + $module = 'RssWidget'; + } + } +} diff --git a/plugins/RssWidget/Widgets/RssChangelog.php b/plugins/RssWidget/Widgets/RssChangelog.php new file mode 100644 index 0000000000..bdd02843ef --- /dev/null +++ b/plugins/RssWidget/Widgets/RssChangelog.php @@ -0,0 +1,49 @@ +setCategoryId('About Piwik'); + $config->setName('Piwik Changelog'); + } + + public function render() + { + try { + $rss = new RssRenderer('http://feeds.feedburner.com/PiwikReleases'); + $rss->setCountPosts(1); + $rss->showDescription(true); + $rss->showContent(false); + + return $rss->get(); + + } catch (\Exception $e) { + + return $this->error($e); + } + } + + /** + * @param \Exception $e + * @return string + */ + private function error($e) + { + return '
' + . Piwik::translate('General_ErrorRequest', array('', '')) + . ' - ' . $e->getMessage() . '
'; + } +} diff --git a/plugins/RssWidget/Widgets/RssPiwik.php b/plugins/RssWidget/Widgets/RssPiwik.php new file mode 100644 index 0000000000..41ee915292 --- /dev/null +++ b/plugins/RssWidget/Widgets/RssPiwik.php @@ -0,0 +1,47 @@ +setCategoryId('About Piwik'); + $config->setName('Piwik.org Blog'); + } + + public function render() + { + try { + $rss = new RssRenderer('http://feeds.feedburner.com/Piwik'); + $rss->showDescription(true); + + return $rss->get(); + + } catch (\Exception $e) { + + return $this->error($e); + } + } + + /** + * @param \Exception $e + * @return string + */ + private function error($e) + { + return '
' + . Piwik::translate('General_ErrorRequest', array('', '')) + . ' - ' . $e->getMessage() . '
'; + } +} diff --git a/plugins/RssWidget/plugin.json b/plugins/RssWidget/plugin.json new file mode 100644 index 0000000000..ba44ad733c --- /dev/null +++ b/plugins/RssWidget/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "RssWidget", + "description": "Piwik Platform showcase: how to create a new widget that displays a user submitted RSS feed.", + "version": "1.0", + "keywords": ["example", "feed", "widget"], + "homepage": "http://piwik.org", + "license": "GPL v3+", + "authors": [ + { + "name": "Piwik", + "email": "hello@piwik.org", + "homepage": "http://piwik.org" + } + ] +} \ No newline at end of file diff --git a/plugins/RssWidget/stylesheets/rss.less b/plugins/RssWidget/stylesheets/rss.less new file mode 100644 index 0000000000..11f4d9dbbe --- /dev/null +++ b/plugins/RssWidget/stylesheets/rss.less @@ -0,0 +1,33 @@ +.rss ul { + list-style: none outside none; + padding: 0; +} + +.rss li { + line-height: 140%; + margin: 0.5em 0 1em; +} + +.rss-title, .rss-date { + float: left; + font-size: 14px; + line-height: 140%; +} + +.rss-title { + color: #2583AD; + margin: 0 0.5em 0.2em 0; + font-weight: bold; +} + +.rss-date { + color: #999999; + margin: 0; +} + +.rss-content, .rss-description { + clear: both; + line-height: 1.5em; + font-size: 13px; + color: #333333; +} diff --git a/plugins/Widgetize/tests/System/WidgetTest.php b/plugins/Widgetize/tests/System/WidgetTest.php index 919556ed34..ebc5a5a7bd 100644 --- a/plugins/Widgetize/tests/System/WidgetTest.php +++ b/plugins/Widgetize/tests/System/WidgetTest.php @@ -174,18 +174,18 @@ class WidgetTest extends SystemTestCase ), ),array ( 'name' => 'Piwik Changelog', - 'uniqueId' => 'widgetExampleRssWidgetrssChangelog', + 'uniqueId' => 'widgetRssWidgetrssChangelog', 'parameters' => array ( - 'module' => 'ExampleRssWidget', + 'module' => 'RssWidget', 'action' => 'rssChangelog', ), ),array ( 'name' => 'Piwik.org Blog', - 'uniqueId' => 'widgetExampleRssWidgetrssPiwik', + 'uniqueId' => 'widgetRssWidgetrssPiwik', 'parameters' => array ( - 'module' => 'ExampleRssWidget', + 'module' => 'RssWidget', 'action' => 'rssPiwik', ), ),array ( @@ -1343,19 +1343,19 @@ class WidgetTest extends SystemTestCase ), array ( 'name' => 'Piwik.org Blog', - 'uniqueId' => 'widgetExampleRssWidgetrssPiwik', + 'uniqueId' => 'widgetRssWidgetrssPiwik', 'parameters' => array ( - 'module' => 'ExampleRssWidget', + 'module' => 'RssWidget', 'action' => 'rssPiwik', ), ), array ( 'name' => 'Piwik Changelog', - 'uniqueId' => 'widgetExampleRssWidgetrssChangelog', + 'uniqueId' => 'widgetRssWidgetrssChangelog', 'parameters' => array ( - 'module' => 'ExampleRssWidget', + 'module' => 'RssWidget', 'action' => 'rssChangelog', ), ), diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata.xml index 1443e8873d..69e163bc02 100644 --- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata.xml +++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata.xml @@ -2650,14 +2650,14 @@ - ExampleRssWidget + RssWidget rssChangelog 99 - ExampleRssWidget + RssWidget rssChangelog - widgetExampleRssWidgetrssChangelog + widgetRssWidgetrssChangelog System Summary @@ -2704,14 +2704,14 @@ - ExampleRssWidget + RssWidget rssPiwik 99 - ExampleRssWidget + RssWidget rssPiwik - widgetExampleRssWidgetrssPiwik + widgetRssWidgetrssPiwik Latest Piwik Plugin Updates diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata_day.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata_day.xml index fa3b20ac00..87044426b1 100644 --- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata_day.xml +++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getWidgetMetadata_day.xml @@ -1873,14 +1873,14 @@ Example Widgets - ExampleRssWidget + RssWidget rssChangelog 99 - ExampleRssWidget + RssWidget rssChangelog - widgetExampleRssWidgetrssChangelog + widgetRssWidgetrssChangelog Movers and Shakers @@ -1941,14 +1941,14 @@ Example Widgets - ExampleRssWidget + RssWidget rssPiwik 99 - ExampleRssWidget + RssWidget rssPiwik - widgetExampleRssWidgetrssPiwik + widgetRssWidgetrssPiwik Welcome! diff --git a/tests/resources/screenshot-override/override.css b/tests/resources/screenshot-override/override.css index a332017bdb..59b296f8e3 100644 --- a/tests/resources/screenshot-override/override.css +++ b/tests/resources/screenshot-override/override.css @@ -42,7 +42,7 @@ body > .widget { } /* do not display RSS feed widget's contents */ -#widgetExampleRssWidgetrssPiwik .rss { +#widgetRssWidgetrssPiwik .rss { display:none; } -- cgit v1.2.3