Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 661077bf5d6b79c030bd22d430d9c151b397ce4f @hamishcampbell committed Jan 10, 2010
@@ -0,0 +1,21 @@
+* Copyright (c) 2010, Hamish Campbell
+* All rights reserved
+*
+* Licensed as under the Creative Commons Attribution 3.0
+* New Zealand License, see:
+* http://creativecommons.org/licenses/by/3.0/nz/legalcode
+*
+* Utilizes an unmodified (ie redistributed) version of jscolor
+* (http://jscolor.com/). This licensed onder the GNU Lesser
+* General Public License (http://www.gnu.org/copyleft/lesser.html)
+*
+* THIS SOFTWARE IS PROVIDED BY 'AS IS' AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL Silverstripe Ltd. BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,13 @@
+####################################################
+Twitter Widget Pack v 0.10
+####################################################
+
+# Maintainer Contact
+Hamish Campbell (Nickname: hamish)
+<hn.campbell (at) gmail (dot) com>
+
+# Requirements
+SilverStripe 2.3.0
+
+# Documentation
+http://polemic.net.nz/trac/wiki/TwitterWidgetPack
@@ -0,0 +1 @@
+<?php ?>
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Creates a Twitter Favourite Tweets Widget
+ *
+ * Utilizes the twitter javascript widget class to build a dynamic widget for inclusion
+ * within a SilverStripe Widget area.
+ *
+ * @author Hamish Campbell <hn.campbell@gmail.com>
+ * @copyright copyright (c) 2010, Hamish Campbell
+ * @license http://creativecommons.org/licenses/by/3.0/nz/ CC Attribution 3.0 NZ Licence
+ */
+class TwitterFavesWidget extends TwitterProfileWidget {
+
+ static $title = "Twitter Faves";
+
+ static $cmsTitle = "Twitter Faves Widget";
+
+ static $description = "Displays your favourite tweets from Twitter.com";
+
+ protected $type = 'faves';
+
+ static $db = array(
+ 'FavesTitle' => 'Varchar(255)',
+ 'FavesSubject' => 'Varchar(255)',
+ );
+
+ static $defaults = array(
+ 'FeatureAvatars' => true,
+ );
+
+ function getCMSFields() {
+ $fields = new FieldSet(
+ new TextField('FavesTitle', 'Title'),
+ new TextField('FavesSubject', 'Subject')
+ );
+ $fields->merge(parent::getCMSFields());
+ return $fields;
+ }
+
+ function WidgetSetupJSON() {
+ $settings = $this->WidgetSetup();
+ $settings['type'] = $this->type;
+ $settings['title'] = $this->FavesTitle;
+ $settings['subject'] = $this->FavesSubject;
+ return Convert::raw2json($settings);
+ }
+
+}
+?>
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Creates a Twitter Lists Widget
+ *
+ * Utilizes the twitter javascript widget class to build a dynamic widget for inclusion
+ * within a SilverStripe Widget area.
+ *
+ * @author Hamish Campbell <hn.campbell@gmail.com>
+ * @copyright copyright (c) 2010, Hamish Campbell
+ * @license http://creativecommons.org/licenses/by/3.0/nz/ CC Attribution 3.0 NZ Licence
+ */
+class TwitterListWidget extends TwitterProfileWidget {
+
+ static $title = "Twitter Lists";
+
+ static $cmsTitle = "Twitter Lists Widget";
+
+ static $description = "Displays tweets from a list from Twitter.com";
+
+ protected $type = 'list';
+
+ static $db = array(
+ 'ListTitle' => 'Varchar(255)',
+ 'ListSubject' => 'Varchar(255)',
+ 'ListName' => 'Varchar(255)',
+ );
+
+ static $defaults = array(
+ 'FeatureAvatars' => true,
+ );
+
+ function getCMSFields() {
+ $fields = new FieldSet(
+ new TextField('ListTitle', 'Title'),
+ new TextField('ListSubject', 'Subject'),
+ new TextField('ListName', 'List Name')
+ );
+ $fields->merge(parent::getCMSFields());
+ return $fields;
+ }
+
+ function ListName() {
+ return Convert::raw2js($this->ListName);
+ }
+
+ function WidgetSetupJSON() {
+ $settings = $this->WidgetSetup();
+ $settings['type'] = $this->type;
+ $settings['title'] = $this->ListTitle;
+ $settings['subject'] = $this->ListSubject;
+ return Convert::raw2json($settings);
+ }
+
+}
+?>
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Creates a Twitter Profile Widget
+ *
+ * Utilizes the twitter javascript widget class to build a dynamic widget for inclusion
+ * within a SilverStripe Widget area.
+ *
+ * @author Hamish Campbell <hn.campbell@gmail.com>
+ * @copyright copyright (c) 2010, Hamish Campbell
+ * @license http://creativecommons.org/licenses/by/3.0/nz/ CC Attribution 3.0 NZ Licence
+ */
+class TwitterProfileWidget extends Widget {
+
+ static $title = "Twitter Profile";
+
+ static $cmsTitle = "Twitter Profile Widget";
+
+ static $description = "Displays tweets live from Twitter.com";
+
+ protected $type = 'profile';
+
+ protected $version = 2;
+
+ static $db = array(
+ 'TwitterUser' => 'Varchar(20)',
+ 'TweetCount' => 'Int',
+ 'TweetInterval' => 'Int',
+ 'SizeHeight' => 'Int',
+ 'SizeWidth' => 'Int',
+ 'SizeWidthAuto' => 'Boolean',
+ 'ShellBackground' => 'Varchar(7)',
+ 'ShellColor' => 'Varchar(7)',
+ 'TweetBackground' => 'Varchar(7)',
+ 'TweetColor' => 'Varchar(7)',
+ 'LinkColor' => 'Varchar(7)',
+ 'FeatureScrollbars' => 'Boolean',
+ 'FeatureLoop' => 'Boolean',
+ 'FeatureLive' => 'Boolean',
+ 'FeatureHashtags' => 'Boolean',
+ 'FeatureTimestamp' => 'Boolean',
+ 'FeatureAvatars' => 'Boolean',
+ 'FeatureBehavior' => "Enum('default, all', 'default')",
+ );
+
+ static $defaults = array(
+ 'TweetCount' => 4,
+ 'TweetInterval' => 10000,
+ 'SizeHeight' => 300,
+ 'SizeWidth' => 250,
+ 'SizeWidthAuto' => true,
+ 'ShellBackground' => '#333333',
+ 'ShellColor' => '#ffffff',
+ 'TweetBackground' => '#000000',
+ 'TweetColor' => '#ffffff',
+ 'LinkColor' => '#4AED05',
+ 'FeatureScrollbars' => false,
+ 'FeatureLoop' => false,
+ 'FeatureLive' => false,
+ 'FeatureHashtags' => true,
+ 'FeatureTimestamp' => true,
+ 'FeatureAvatars' => false,
+ 'FeatureBehavior' => 'default',
+ );
+
+ function getCMSFields() {
+ $fields = new Fieldset(
+ new TextField('TwitterUser', 'Account Name'),
+ new DropdownField('TweetCount', 'Number of Tweets', range(1, 20)),
+ new NumericField('SizeHeight', 'Height (px)'),
+ new TextField('ShellBackground', 'UI Background Color'),
+ new TextField('ShellColor', 'UI Text Color'),
+ new TextField('TweetBackground', 'Tweet Background Color'),
+ new TextField('TweetColor', 'Tweet Background Color'),
+ new TextField('LinkColor', 'Link Color'),
+ new CheckboxField('FeatureScrollbars', 'Display Scrollbars'),
+ new CheckboxField('FeatureLoop', 'Loop Results'),
+ new CheckboxField('FeatureHashtags', 'Display Hashtags'),
+ new CheckboxField('FeatureTimestamp', 'Display Timestamp'),
+ new CheckboxField('FeatureAvatars', 'Display Avatars')
+ );
+ return $fields;
+ }
+
+ function User() {
+ return Convert::raw2js($this->TwitterUser);
+ }
+
+ protected function WidgetSetup() {
+ return array(
+ 'version' => $this->version,
+ 'type' => $this->type,
+ 'rpp' => $this->TweetCount,
+ 'interval' => $this->TweetInterval,
+ 'width' => ($this->SizeWidthAuto ? 'auto' : $this->SizeWidth),
+ 'height' => $this->Height,
+ 'theme' => array(
+ 'shell' => array(
+ 'background' => $this->ShellBackground,
+ 'color' => $this->ShellColor,
+ ),
+ 'tweets' => array(
+ 'background' => $this->TweetBackground,
+ 'color' => $this->TweetColor,
+ 'links' => $this->LinkColor,
+ )
+ ),
+ 'features' => array(
+ 'scrollbar' => ($this->FeatureScrollbars ? true : false),
+ 'loop' => ($this->FeatureLoop ? true : false),
+ 'live' => ($this->FeatureLive ? true : false),
+ 'hashtags' => ($this->FeatureHashTags ? true : false),
+ 'timestamp' => ($this->FeatureTimestamp ? true : false),
+ 'avatars' => ($this->FeatureAvatars ? true : false),
+ 'behavior' => $this->FeatureBehavior,
+ )
+ );
+ }
+
+ function WidgetSetupJSON() {
+ $settings = $this->WidgetSetup();
+ return Convert::raw2json($settings);
+ }
+
+}
+?>
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Creates a Twitter Search Widget
+ *
+ * Utilizes the twitter javascript widget class to build a dynamic widget for inclusion
+ * within a SilverStripe Widget area.
+ *
+ * @author Hamish Campbell <hn.campbell@gmail.com>
+ * @copyright copyright (c) 2010, Hamish Campbell
+ * @license http://creativecommons.org/licenses/by/3.0/nz/ CC Attribution 3.0 NZ Licence
+ */
+class TwitterSearchWidget extends TwitterProfileWidget {
+
+ static $title = "Twitter Search";
+
+ static $cmsTitle = "Twitter Search Widget";
+
+ static $description = "Displays tweets from Twitter.com";
+
+ protected $type = 'search';
+
+ static $db = array(
+ 'SearchPhrase' => 'Varchar(255)',
+ 'SearchTitle' => 'Varchar(255)',
+ 'SearchSubject' => 'Varchar(255)',
+ );
+
+ static $defaults = array(
+ 'FeatureAvatars' => true,
+ );
+
+ function getCMSFields() {
+ $fields = new FieldSet(
+ new TextField('SearchPhrase', 'Search For'),
+ new TextField('SearchTitle', 'Title'),
+ new TextField('SearchSubject', 'Subject')
+ );
+ $fields->merge(parent::getCMSFields());
+ $fields->removeByName('TwitterUser');
+ return $fields;
+ }
+
+ function WidgetSetupJSON() {
+ $settings = $this->WidgetSetup();
+ $settings['type'] = $this->type;
+ $settings['title'] = $this->SearchTitle;
+ $settings['search'] = $this->SearchPhrase;
+ $settings['subject'] = $this->SearchSubject;
+ return Convert::raw2json($settings);
+ }
+
+}
+?>
@@ -0,0 +1,2 @@
+<script src="http://widgets.twimg.com/j/2/widget.js"></script>
+<script>new TWTR.Widget($WidgetSetupJSON).render().setUser('$User').start();</script>
@@ -0,0 +1,2 @@
+<script src="http://widgets.twimg.com/j/2/widget.js"></script>
+<script>new TWTR.Widget($WidgetSetupJSON).render().setList('$User', '$ListName').start();</script>
@@ -0,0 +1,2 @@
+<script src="http://widgets.twimg.com/j/2/widget.js"></script>
+<script>new TWTR.Widget($WidgetSetupJSON).render().setUser('$User').start();</script>
@@ -0,0 +1,2 @@
+<script src="http://widgets.twimg.com/j/2/widget.js"></script>
+<script>new TWTR.Widget($WidgetSetupJSON).render().start();</script>

0 comments on commit 661077b

Please sign in to comment.