]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'master' into 0.9.x
authorBrion Vibber <brion@pobox.com>
Tue, 21 Sep 2010 19:48:16 +0000 (12:48 -0700)
committerBrion Vibber <brion@pobox.com>
Tue, 21 Sep 2010 19:48:16 +0000 (12:48 -0700)
1  2 
lib/action.php
lib/activityobject.php
lib/adminpanelaction.php
plugins/Disqus/DisqusPlugin.php
plugins/SubMirror/lib/mirrorqueuehandler.php
plugins/TwitterBridge/daemons/twitterstatusfetcher.php

diff --combined lib/action.php
index 5dcf78dcc964e9aa14ed4585cd2d2df44cf5a0eb,dc21c75e5a917704b2863398e39cd221c0ab1c3a..5482ac3773fde68a03f04ad6169519c40944e145
@@@ -715,14 -715,14 +715,14 @@@ class Action extends HTMLOutputter // l
      {
          $this->elementStart('div', array('id' => 'aside_primary',
                                           'class' => 'aside'));
-         if (Event::handle('StartShowExportData', array($this))) {
-             $this->showExportData();
-             Event::handle('EndShowExportData', array($this));
-         }
          if (Event::handle('StartShowSections', array($this))) {
              $this->showSections();
              Event::handle('EndShowSections', array($this));
          }
+         if (Event::handle('StartShowExportData', array($this))) {
+             $this->showExportData();
+             Event::handle('EndShowExportData', array($this));
+         }
          $this->elementEnd('div');
      }
  
          $this->elementStart('dd', null);
          if (common_config('site', 'broughtby')) {
              // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set.
 +            // TRANS: Text between [] is a link description, text between () is the link itself.
 +            // TRANS: Make sure there is no whitespace between "]" and "(".
 +            // TRANS: "%%site.broughtby%%" is the value of the variable site.broughtby
              $instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).');
          } else {
              // TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set.
          }
          $instr .= ' ';
          // TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license.
 +        // TRANS: Make sure there is no whitespace between "]" and "(".
 +        // TRANS: Text between [] is a link description, text between () is the link itself.
 +        // TRANS: %s is the version of StatusNet that is being used.
          $instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION);
          $output = common_markup_to_html($instr);
          $this->raw($output);
                                              'width' => '80',
                                              'height' => '15'));
                  $this->text(' ');
 -                // TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
 +                // TRANS: license message in footer.
 +                // TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
                  $notice = _('All %1$s content and data are available under the %2$s license.');
                  $link = "<a class=\"license\" rel=\"external license\" href=\"" .
                          htmlspecialchars(common_config('license', 'url')) .
              }
          }
  
 +        $checked = false;
          if ($etag) {
              $if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
                $_SERVER['HTTP_IF_NONE_MATCH'] : null;
 -            if ($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
 -                header('HTTP/1.1 304 Not Modified');
 -                // Better way to do this?
 -                exit(0);
 +            if ($if_none_match) {
 +                // If this check fails, ignore the if-modified-since below.
 +                $checked = true;
 +                if ($this->_hasEtag($etag, $if_none_match)) {
 +                    header('HTTP/1.1 304 Not Modified');
 +                    // Better way to do this?
 +                    exit(0);
 +                }
              }
          }
  
 -        if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
 +        if (!$checked && $lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
              $if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
              $ims = strtotime($if_modified_since);
              if ($lm <= $ims) {
          // CSRF protection
          $token = $this->trimmed('token');
          if (empty($token) || $token != common_session_token()) {
 +            // TRANS: Client error text when there is a problem with the session token.
              $this->clientError(_('There was a problem with your session token.'));
          }
      }
diff --combined lib/activityobject.php
index 0fc06948bb0d880d43fe4a869986a77df5794534,444577775f52b9c2f5a57a9d110aae4a0aa28fe3..95615d581c8266537e02f1145176b08a048d9b2e
@@@ -168,6 -168,7 +168,6 @@@ class ActivityObjec
                  ActivityObject::MEDIA_DESCRIPTION,
                  Activity::MEDIA
              );
 -
          }
      }
  
          );
  
          foreach ($sizes as $size) {
 -
              $alink  = null;
              $avatar = $profile->getAvatar($size);
  
                  $alink->height = $size;
                  $alink->width  = $size;
                  $alink->url    = Avatar::defaultImage($size);
+                 if ($size == AVATAR_PROFILE_SIZE) {
+                     // Hack for Twitter import: we don't have a 96x96 image,
+                     // but we do have a 73x73 image. For now, fake it with that.
+                     $avatar = $profile->getAvatar(73);
+                     if ($avatar) {
+                         $alink = AvatarLink::fromAvatar($avatar);
+                         $alink->height= $size;
+                         $alink->width = $size;
+                     }
+                 }
              }
  
              $object->avatarLinks[] = $alink;
diff --combined lib/adminpanelaction.php
index 5c414bbd7b505a357c3c7c06b09bc1b32d4497f2,043219a1fe40c0948907c4ed92208530d376f2e3..fae9f4fa57a83a9b4a4f6542862013209c82be58
@@@ -44,6 -44,7 +44,6 @@@ if (!defined('STATUSNET')) 
   *
   * @todo Find some commonalities with SettingsAction and combine
   */
 -
  class AdminPanelAction extends Action
  {
      var $success = true;
@@@ -60,6 -61,7 +60,6 @@@
       *
       * @return boolean success flag
       */
 -
      function prepare($args)
      {
          parent::prepare($args);
       *
       * @return void
       */
 -
      function handle($args)
      {
          if ($_SERVER['REQUEST_METHOD'] == 'POST') {
       * @return void
       * @see AdminPanelNav
       */
 -
      function showLocalNav()
      {
          $nav = new AdminPanelNav($this);
       *
       * @return void.
       */
 -
      function showContent()
      {
          $this->showForm();
       *
       * @return void
       */
 -
      function showPageNotice()
      {
          if ($this->msg) {
       *
       * @return void
       */
 -
      function showForm()
      {
          // TRANS: Client error message.
       *
       * @return void
       */
 -
      function getInstructions()
      {
          return '';
       *
       * @return void
       */
 -
      function saveSettings()
      {
          // TRANS: Client error message
       *
       * @return mixed $result false if something didn't work
       */
 -
      function deleteSetting($section, $setting)
      {
          $config = new Config();
   *
   * @see      Widget
   */
 -
  class AdminPanelNav extends Widget
  {
      var $action = null;
       *
       * @param Action $action current action, used for output
       */
 -
      function __construct($action=null)
      {
          parent::__construct($action);
       *
       * @return void
       */
 -
      function show()
      {
          $action_name = $this->action->trimmed('action');
                                       $menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel');
              }
  
+             if (AdminPanelAction::canAdmin('license')) {
+                 // TRANS: Menu item title/tooltip
+                 $menu_title = _('Set site license');
+                 // TRANS: Menu item for site administration
+                 $this->out->menuItem(common_local_url('licenseadminpanel'), _('License'),
+                                      $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel');
+             }
              Event::handle('EndAdminPanelNav', array($this));
          }
          $this->action->elementEnd('ul');
      }
 -
  }
index 681be19dc97b9dafdf96b0d4fd7c31be6ccd64b3,0000000000000000000000000000000000000000..3901562f98fe02131c2db30c4f3d82106b7e0a90
mode 100644,000000..100644
--- /dev/null
@@@ -1,171 -1,0 +1,174 @@@
 +<?php
 +/**
 + * StatusNet, the distributed open-source microblogging tool
 + *
 + * Plugin to add Disqus commenting to notice pages
 + *
 + * PHP version 5
 + *
 + * LICENCE: This program is free software: you can redistribute it and/or modify
 + * it under the terms of the GNU Affero General Public License as published by
 + * the Free Software Foundation, either version 3 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU Affero General Public License for more details.
 + *
 + * You should have received a copy of the GNU Affero General Public License
 + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 + *
 + * @category  Plugin
 + * @package   StatusNet
 + * @author    Zach Copley <zach@status.net>
 + * @copyright 2010 StatusNet, Inc.
 + * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 + * @link      http://status.net/
 + */
 +
 +if (!defined('STATUSNET')) {
 +    exit(1);
 +}
 +
 +/**
 + *
 + * This plugin adds Disqus commenting to your notices. Enabling this
 + * plugin will make each notice page display the Disqus widget, and
 + * notice lists will display the number of commments each notice has.
 + *
 + * To use this plugin, you need to first register your site with Disqus
 + * and get a Discus 'shortname' for it.
 + *
 + *    http://disqus.com
 + *
 + * To enable the plugin, put the following in you config.php:
 + *
 + * addPlugin(
 + *   'Disqus', array(
 + *       'shortname' => 'YOURSHORTNAME',
 + *      'div_style' => 'width:675px; padding-top:10px; position:relative; float:left;'
 + *   )
 + * );
 + *
 + * NOTE: the 'div_style' in an optional parameter that passes in some
 + * inline CSS when creating the Disqus widget. It's a shortcut to make
 + * the widget look OK with the default StatusNet theme. If you leave
 + * it out you'll have to edit your theme CSS files to make the widget
 + * look good.  You can also control the way the widget looks by
 + * adding style rules to your theme.
 + *
 + * See: http://help.disqus.com/entries/100878-css-customization
 + *
 + * @category Plugin
 + * @package  StatusNet
 + * @author   Zach Copley <zach@status.net>
 + * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
 + * @link     http://status.net/
 + *
 + * @see      Event
 + */
 +class DisqusPlugin extends Plugin
 +{
++    public $shortname; // Required 'shortname' for actually triggering Disqus.
++    public $div_style; // Optional CSS chunk for the main <div>
++
 +    function onEndShowContentBlock($action)
 +    {
 +        if (get_class($action) == 'ShownoticeAction') {
 +
 +            $attrs = array();
 +            $attrs['id'] = 'disqus_thread';
 +
 +            if ($this->div_style) {
 +                $attrs['style'] = $this->div_style;
 +            }
 +
 +            $action->element('div', $attrs, null);
 +
 +            $script = <<<ENDOFSCRIPT
 +var disqus_identifier = %d;
 +  (function() {
 +   var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
 +   dsq.src = 'http://%s.disqus.com/embed.js';
 +   (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
 +  })();
 +ENDOFSCRIPT;
 +
 +            $action->inlineScript(sprintf($script, $action->notice->id, $this->shortname));
 +
 +            $attrs = array();
 +
 +            $attrs['id'] = 'disqus_thread_footer';
 +
 +            if ($this->div_style) {
 +                $attrs['style'] = $this->div_style;
 +            }
 +
 +            $action->elementStart('div', $attrs);
 +            $action->elementStart('noscript');
 +
 +                      // @todo FIXME: No i18n yet, because of bad implementation. Should be one string.
 +            $action->raw('Please enable JavaScript to view the ');
 +            $noscriptUrl = 'http://disqus.com/?ref_noscript=' . $this->shortname;
 +            $action->element('a', array('href' => $noscriptUrl), 'comments powered by Disqus.');
 +            $action->elementEnd('noscript');
 +
 +            $action->elementStart('a', array('href' => 'http://disqus.com', 'class' => 'dsq-brlink'));
 +            $action->raw('blog comments powered by ');
 +            $action->element('span', array('class' => 'logo-disqus'), 'Disqus');
 +            $action->elementEnd('a');
 +            $action->elementEnd('div');
 +        }
 +    }
 +
 +    function onEndShowScripts($action)
 +    {
 +        // fugly
 +        $script = <<<ENDOFSCRIPT
 +var disqus_shortname = '%s';
 +(function () {
 +  var s = document.createElement('script'); s.async = true;
 +  s.src = 'http://disqus.com/forums/%s/count.js';
 +  (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
 +}());
 +ENDOFSCRIPT;
 +        $action->inlineScript(sprintf($script, $this->shortname, $this->shortname));
 +
 +        return true;
 +    }
 +
 +    function onStartShowNoticeItem($noticeListItem)
 +    {
 +        if (empty($noticeListItem->notice->is_local)) {
 +            return true;
 +        }
 +
 +        $noticeListItem->showNotice();
 +        $noticeListItem->showNoticeInfo();
 +
 +        $noticeUrl = $noticeListItem->notice->bestUrl();
 +        $noticeUrl .= '#disqus_thread';
 +
 +        $noticeListItem->out->element(
 +            'a', array('href' => $noticeUrl, 'class' => 'disqus_count'), 'Comments'
 +        );
 +
 +        $noticeListItem->showNoticeOptions();
 +        Event::handle('EndShowNoticeItem', array($noticeListItem));
 +
 +        return false;
 +    }
 +
 +    function onPluginVersion(&$versions)
 +    {
 +        $versions[] = array('name' => 'Disqus',
 +                            'version' => STATUSNET_VERSION,
 +                            'author' => 'Zach Copley',
 +                            'homepage' => 'http://status.net/wiki/Plugin:Disqus',
 +                            'rawdescription' =>
 +                            _m('Use <a href="http://disqus.com/">Disqus</a>'.
 +                               ' to add commenting to notice pages.'));
 +        return true;
 +    }
 +}
index dae9c088953d92d58adf235d04cf750c83d1114a,c1a6f65e3817572e9c503ed2a204b11cf5f5caf1..550986b444ce1a4be3646252c00a0f87d8836e9f
@@@ -23,6 -23,7 +23,6 @@@
   * @package SubMirror
   * @author Brion Vibber <brion@status.net>
   */
 -
  class MirrorQueueHandler extends QueueHandler
  {
      function transport()
          $mirror->subscribed = $notice->profile_id;
          if ($mirror->find()) {
              while ($mirror->fetch()) {
-                 $mirror->mirrorNotice($notice);
+                 try {
+                     $mirror->mirrorNotice($notice);
+                 } catch (Exception $e) {
+                     common_log(LOG_ERR, "Exception trying to mirror notice $notice->id " .
+                                         "for subscriber $mirror->subscriber ($mirror->style): " .
+                                         $e->getMessage());
+                 }
              }
          }
          return true;
index 31129b96d9e452ce63d9e21d7299457dd688a6dc,181be3dcf3827a7dc812db7ae0b7cdef4af5b763..590fa2954d1ac467c65d2f23a97917a9b1ef59e6
@@@ -62,6 -62,7 +62,6 @@@ require_once INSTALLDIR . '/plugins/Twi
   * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
   * @link     http://status.net/
   */
 -
  class TwitterStatusFetcher extends ParallelizingDaemon
  {
      /**
@@@ -86,6 -87,7 +86,6 @@@
       *
       * @return string Name of the daemon.
       */
 -
      function name()
      {
          return ('twitterstatusfetcher.'.$this->_id);
@@@ -97,6 -99,7 +97,6 @@@
       *
       * @return array flinks an array of Foreign_link objects
       */
 -
      function getObjects()
      {
          global $_DB_DATAOBJECT;
      }
  
      function childTask($flink) {
 -
          // Each child ps needs its own DB connection
  
          // Note: DataObject::getDatabaseConnection() creates
          // a new connection if there isn't one already
 -
          $conn = &$flink->getDatabaseConnection();
  
          $this->getTimeline($flink);
  
          // XXX: Couldn't find a less brutal way to blow
          // away a cached connection
 -
          global $_DB_DATAOBJECT;
          unset($_DB_DATAOBJECT['CONNECTIONS']);
      }
          // Reverse to preserve order
  
          foreach (array_reverse($timeline) as $status) {
 -
              // Hacktastic: filter out stuff coming from this StatusNet
 -
              $source = mb_strtolower(common_config('integration', 'source'));
  
              if (preg_match("/$source/", mb_strtolower($status->source))) {
  
              // Don't save it if the user is protected
              // FIXME: save it but treat it as private
 -
              if ($status->user->protected) {
                  continue;
              }
          }
  
          // Okay, record the time we synced with Twitter for posterity
 -
          $flink->last_noticesync = common_sql_now();
          $flink->update();
      }
          $statusUri = $this->makeStatusURI($status->user->screen_name, $status->id);
  
          // check to see if we've already imported the status
 -
          $n2s = Notice_to_status::staticGet('status_id', $status->id);
  
          if (!empty($n2s)) {
          }
  
          // If it's a retweet, save it as a repeat!
 -
          if (!empty($status->retweeted_status)) {
              common_log(LOG_INFO, "Status {$status->id} is a retweet of {$status->retweeted_status->id}.");
              $original = $this->saveStatus($status->retweeted_status);
                  $author = $original->getProfile();
                  // TRANS: Message used to repeat a notice. RT is the abbreviation of 'retweet'.
                  // TRANS: %1$s is the repeated user's name, %2$s is the repeated notice.
 -                $content = sprintf(_('RT @%1$s %2$s'),
 +                $content = sprintf(_m('RT @%1$s %2$s'),
                                     $author->nickname,
                                     $original->content);
  
       *
       * @return string URI
       */
 -
      function makeStatusURI($username, $id)
      {
          return 'http://twitter.com/'
       *
       * @return mixed value the first Profile with that url, or null
       */
 -
      function getProfileByUrl($nickname, $profileurl)
      {
          $profile = new Profile();
       *
       * @return mixed value a matching Notice or null
       */
 -
      function checkDupe($profile, $statusUri)
      {
          $notice = new Notice();
      function ensureProfile($user)
      {
          // check to see if there's already a profile for this user
 -
          $profileurl = 'http://twitter.com/' . $user->screen_name;
          $profile = $this->getProfileByUrl($user->screen_name, $profileurl);
  
              return $profile;
  
          } else {
 -
              common_debug($this->name() . ' - Adding profile and remote profile ' .
                           "for Twitter user: $profileurl.");
  
              $remote_pro = Remote_profile::staticGet('uri', $profileurl);
  
              if (empty($remote_pro)) {
 -
                  $remote_pro = new Remote_profile();
  
                  $remote_pro->id = $id;
          $avatar = $profile->getAvatar($sizes[$size]);
  
          // Delete the avatar, if present
 -
          if ($avatar) {
              $avatar->delete();
          }
              $avatar->height = 48;
              break;
          default:
 -
              // Note: Twitter's big avatars are a different size than
              // StatusNet's (StatusNet's = 96)
 -
              $avatar->width  = 73;
              $avatar->height = 73;
          }
          $text = $status->text;
  
          if (empty($status->entities)) {
+             common_log(LOG_WARNING, "No entities data for {$status->id}; trying to fake up links ourselves.");
+             $text = common_replace_urls_callback($text, 'common_linkify');
+             $text = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.TwitterStatusFetcher::tagLink('\\2')", $text);
+             $text = preg_replace('/(^|\s+)@([a-z0-9A-Z_]{1,64})/e', "'\\1@'.TwitterStatusFetcher::atLink('\\2')", $text);
              return $text;
          }
  
  
      function makeHashtagLink($object)
      {
-         return "#<a href='https://twitter.com/search?q=%23{$object->text}' class='hashtag'>{$object->text}</a>";
+         return "#" . self::tagLink($object->text);
      }
  
      function makeMentionLink($object)
      {
-         return "@<a href='http://twitter.com/{$object->screen_name}' title='{$object->name}'>{$object->screen_name}</a>";
+         return "@".self::atLink($object->screen_name, $object->name);
+     }
+     static function tagLink($tag)
+     {
+         return "<a href='https://twitter.com/search?q=%23{$tag}' class='hashtag'>{$tag}</a>";
+     }
+     static function atLink($screenName, $fullName=null)
+     {
+         if (!empty($fullName)) {
+             return "<a href='http://twitter.com/{$screenName}' title='{$fullName}'>{$screenName}</a>";
+         } else {
+             return "<a href='http://twitter.com/{$screenName}'>{$screenName}</a>";
+         }
      }
  
      function saveStatusMentions($notice, $status)
@@@ -801,3 -840,4 +819,3 @@@ if (have_option('d') || have_option('de
  
  $fetcher = new TwitterStatusFetcher($id, 60, 2, $debug);
  $fetcher->runOnce();
 -