From c4040303cecc48aed66d0102de6b9f5ffdc64b22 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 10:18:16 -0400 Subject: [PATCH 01/35] initial snapshot stuff --- lib/common.php | 3 ++ lib/snapshot.php | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 lib/snapshot.php diff --git a/lib/common.php b/lib/common.php index dd2570e751..f81c3dc76d 100644 --- a/lib/common.php +++ b/lib/common.php @@ -157,6 +157,9 @@ $config = 'newuser' => array('subscribe' => null, 'welcome' => null), + 'snapshot' => + array('run' => 'web', + 'frequency' => 10000), ); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); diff --git a/lib/snapshot.php b/lib/snapshot.php new file mode 100644 index 0000000000..4f9bb3f62e --- /dev/null +++ b/lib/snapshot.php @@ -0,0 +1,101 @@ +. + * + * @category Stats + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +/** + * A snapshot of site stats that can report itself to headquarters + * + * This class will collect statistics on the site and report them to + * a statistics server of the admin's choice. (Default is the big one + * at laconi.ca.) + * + * It can either be called from a cron job, or run occasionally by the + * Web site. + * + * @category Stats + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + */ + +class Snapshot { + + function __construct() + { + } + + function take() + { + } + + function report() + { + } + + static function check() + { + switch (common_config('snapshot', 'run')) { + case 'web': + // skip if we're not running on the Web. + if (!isset($_SERVER) || !array_key_exists('REQUEST_METHOD', $_SERVER)) { + break; + } + // Run once every frequency hits + // XXX: do frequency by time (once a week, etc.) rather than + // hits + if (rand() % common_config('snapshot', 'frequency') == 0) { + $snapshot = new Snapshot(); + if ($snapshot->take()) { + $snapshot->report(); + } + } + break; + case 'cron': + // skip if we're running on the Web + if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + break; + } + // We're running from the command line; assume + $snapshot = new Snapshot(); + if ($snapshot->take()) { + $snapshot->report(); + } + break; + case 'never': + break; + default: + common_log(LOG_WARNING, "Unrecognized value for snapshot run config."); + } + } +} From 5128448c777e74c0e294c21ce80711c04395d6d4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 12:41:30 -0400 Subject: [PATCH 02/35] code complete on snapshot.php --- lib/snapshot.php | 88 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/lib/snapshot.php b/lib/snapshot.php index 4f9bb3f62e..338c8d559d 100644 --- a/lib/snapshot.php +++ b/lib/snapshot.php @@ -51,18 +51,12 @@ if (!defined('LACONICA')) { class Snapshot { + var $stats = null; + function __construct() { } - function take() - { - } - - function report() - { - } - static function check() { switch (common_config('snapshot', 'run')) { @@ -98,4 +92,82 @@ class Snapshot { common_log(LOG_WARNING, "Unrecognized value for snapshot run config."); } } + + function take() + { + $this->stats = array(); + + // Some basic identification stuff + + $this->stats['version'] = LACONICA_VERSION; + $this->stats['phpversion'] = phpversion(); + $this->stats['name'] = common_config('site', 'name'); + $this->stats['root'] = common_root_url(); + + // non-identifying stats on various tables. Primary + // interest is size and rate of activity of service. + + $tables = array('user', + 'notice', + 'subscription', + 'remote_profile', + 'user_group'); + + foreach ($tables as $table) { + $this->tableStats($table); + } + + // stats on some important config options + + $this->stats['theme'] = common_config('site', 'theme'); + $this->stats['dbtype'] = common_config('db', 'type'); + $this->stats['xmpp'] = common_config('xmpp', 'enabled'); + $this->stats['inboxes'] = common_config('inboxes', 'enabled'); + $this->stats['queue'] = common_config('queue', 'enabled'); + $this->stats['license'] = common_config('license', 'url'); + $this->stats['fancy'] = common_config('site', 'fancy'); + $this->stats['private'] = common_config('site', 'private'); + $this->stats['closed'] = common_config('site', 'closed'); + $this->stats['memcached'] = common_config('memcached', 'enabled'); + $this->stats['language'] = common_config('site', 'language'); + $this->stats['timezone'] = common_config('site', 'timezone'); + } + + function report() + { + // XXX: Use OICU2 and OAuth to make authorized requests + + $postdata = http_build_query($this->stats); + + $opts = array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $postdata, + 'user_agent' => 'Laconica/'.LACONICA_VERSION + ) + ); + + $context = stream_context_create($opts); + + $reporturl = common_config('snapshot', 'reporturl'); + + $result = file_get_contents($reporturl, false, $context); + } + + function tableStats($table) + { + $inst = DB_DataObject::Factory($table); + $res = $inst->query('SELECT count(*) as cnt, '. + 'min(created) as first, '. + 'max(created) as last '. + 'from ' . $table); + if ($res) { + $this->stats[$table.'count'] = $inst->cnt; + $this->stats[$table.'first'] = $inst->first; + $this->stats[$table.'last'] = $inst->last; + } + $inst->free(); + unset($inst); + } } From 415abdfdef64608d6c4ba081dd21575e1920770b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 12:50:13 -0400 Subject: [PATCH 03/35] config options for snapshots --- lib/common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index f81c3dc76d..05539af834 100644 --- a/lib/common.php +++ b/lib/common.php @@ -159,7 +159,8 @@ $config = 'welcome' => null), 'snapshot' => array('run' => 'web', - 'frequency' => 10000), + 'frequency' => 10000, + 'reporturl' => 'http://laconi.ca/stats/report'), ); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); From 6a247acb45198c3748df48d8b14b71c8f8b839de Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 12:50:29 -0400 Subject: [PATCH 04/35] Do some phpcs reformatting for snapshot --- lib/snapshot.php | 107 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 29 deletions(-) diff --git a/lib/snapshot.php b/lib/snapshot.php index 338c8d559d..a014d3435f 100644 --- a/lib/snapshot.php +++ b/lib/snapshot.php @@ -49,18 +49,32 @@ if (!defined('LACONICA')) { * */ -class Snapshot { - +class Snapshot +{ var $stats = null; + /** + * Constructor for a snapshot + */ + function __construct() { } + /** + * Static function for reporting statistics + * + * This function checks whether it should report statistics, based on + * the current configuation settings. If it should, it creates a new + * Snapshot object, takes a snapshot, and reports it to headquarters. + * + * @return void + */ + static function check() { switch (common_config('snapshot', 'run')) { - case 'web': + case 'web': // skip if we're not running on the Web. if (!isset($_SERVER) || !array_key_exists('REQUEST_METHOD', $_SERVER)) { break; @@ -75,7 +89,7 @@ class Snapshot { } } break; - case 'cron': + case 'cron': // skip if we're running on the Web if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { break; @@ -86,23 +100,33 @@ class Snapshot { $snapshot->report(); } break; - case 'never': + case 'never': break; - default: + default: common_log(LOG_WARNING, "Unrecognized value for snapshot run config."); } } + /** + * Take a snapshot of the server + * + * Builds an array of statistical and configuration data based + * on the local database and config files. We avoid grabbing any + * information that could be personal or private. + * + * @return void + */ + function take() { $this->stats = array(); // Some basic identification stuff - $this->stats['version'] = LACONICA_VERSION; + $this->stats['version'] = LACONICA_VERSION; $this->stats['phpversion'] = phpversion(); - $this->stats['name'] = common_config('site', 'name'); - $this->stats['root'] = common_root_url(); + $this->stats['name'] = common_config('site', 'name'); + $this->stats['root'] = common_root_url(); // non-identifying stats on various tables. Primary // interest is size and rate of activity of service. @@ -119,34 +143,44 @@ class Snapshot { // stats on some important config options - $this->stats['theme'] = common_config('site', 'theme'); - $this->stats['dbtype'] = common_config('db', 'type'); - $this->stats['xmpp'] = common_config('xmpp', 'enabled'); - $this->stats['inboxes'] = common_config('inboxes', 'enabled'); - $this->stats['queue'] = common_config('queue', 'enabled'); - $this->stats['license'] = common_config('license', 'url'); - $this->stats['fancy'] = common_config('site', 'fancy'); - $this->stats['private'] = common_config('site', 'private'); - $this->stats['closed'] = common_config('site', 'closed'); + $this->stats['theme'] = common_config('site', 'theme'); + $this->stats['dbtype'] = common_config('db', 'type'); + $this->stats['xmpp'] = common_config('xmpp', 'enabled'); + $this->stats['inboxes'] = common_config('inboxes', 'enabled'); + $this->stats['queue'] = common_config('queue', 'enabled'); + $this->stats['license'] = common_config('license', 'url'); + $this->stats['fancy'] = common_config('site', 'fancy'); + $this->stats['private'] = common_config('site', 'private'); + $this->stats['closed'] = common_config('site', 'closed'); $this->stats['memcached'] = common_config('memcached', 'enabled'); - $this->stats['language'] = common_config('site', 'language'); - $this->stats['timezone'] = common_config('site', 'timezone'); + $this->stats['language'] = common_config('site', 'language'); + $this->stats['timezone'] = common_config('site', 'timezone'); } + /** + * Reports statistics to headquarters + * + * Posts statistics to a reporting server. + * + * @return void + */ + function report() { // XXX: Use OICU2 and OAuth to make authorized requests $postdata = http_build_query($this->stats); - $opts = array('http' => - array( - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', - 'content' => $postdata, - 'user_agent' => 'Laconica/'.LACONICA_VERSION - ) - ); + $opts = + array('http' => + array( + 'method' => 'POST', + 'header' => 'Content-type: '. + 'application/x-www-form-urlencoded', + 'content' => $postdata, + 'user_agent' => 'Laconica/'.LACONICA_VERSION + ) + ); $context = stream_context_create($opts); @@ -155,18 +189,33 @@ class Snapshot { $result = file_get_contents($reporturl, false, $context); } + /** + * Updates statistics for a single table + * + * Determines the size of a table and its oldest and newest rows. + * Goal here is to see how active a site is. Note that it + * fills up the instance stats variable. + * + * @param string $table name of table to check + * + * @return void + */ + function tableStats($table) { $inst = DB_DataObject::Factory($table); + $res = $inst->query('SELECT count(*) as cnt, '. 'min(created) as first, '. 'max(created) as last '. 'from ' . $table); + if ($res) { $this->stats[$table.'count'] = $inst->cnt; $this->stats[$table.'first'] = $inst->first; - $this->stats[$table.'last'] = $inst->last; + $this->stats[$table.'last'] = $inst->last; } + $inst->free(); unset($inst); } From 0838143d5855bb013b355d4abb7ec7a643ef37dc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 12:53:17 -0400 Subject: [PATCH 05/35] allow snapshots to be disabled easily --- lib/common.php | 3 ++- lib/snapshot.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/common.php b/lib/common.php index 05539af834..2c60b04421 100644 --- a/lib/common.php +++ b/lib/common.php @@ -158,7 +158,8 @@ $config = array('subscribe' => null, 'welcome' => null), 'snapshot' => - array('run' => 'web', + array('enabled' => true, + 'run' => 'web', 'frequency' => 10000, 'reporturl' => 'http://laconi.ca/stats/report'), ); diff --git a/lib/snapshot.php b/lib/snapshot.php index a014d3435f..75850a301b 100644 --- a/lib/snapshot.php +++ b/lib/snapshot.php @@ -73,6 +73,10 @@ class Snapshot static function check() { + if (!common_config('snapshot', 'enabled')) { + return; + } + switch (common_config('snapshot', 'run')) { case 'web': // skip if we're not running on the Web. From d76bb2fd115f120d799335069d6bc59203650d55 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 13:05:35 -0400 Subject: [PATCH 06/35] Revert "allow snapshots to be disabled easily" This reverts commit 0838143d5855bb013b355d4abb7ec7a643ef37dc. Already handled with the 'never' option. --- lib/common.php | 3 +-- lib/snapshot.php | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/common.php b/lib/common.php index 37744ebd43..e64ca34da8 100644 --- a/lib/common.php +++ b/lib/common.php @@ -158,8 +158,7 @@ $config = array('subscribe' => null, 'welcome' => null), 'snapshot' => - array('enabled' => true, - 'run' => 'web', + array('run' => 'web', 'frequency' => 10000, 'reporturl' => 'http://laconi.ca/stats/report'), ); diff --git a/lib/snapshot.php b/lib/snapshot.php index 75850a301b..a014d3435f 100644 --- a/lib/snapshot.php +++ b/lib/snapshot.php @@ -73,10 +73,6 @@ class Snapshot static function check() { - if (!common_config('snapshot', 'enabled')) { - return; - } - switch (common_config('snapshot', 'run')) { case 'web': // skip if we're not running on the Web. From b233e7b3f0924d5b8b118098696fe40968b77a45 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 10:16:22 -0700 Subject: [PATCH 07/35] document snapshot options --- README | 26 ++++++++++++++++++++++++++ config.php.sample | 9 +++++++++ 2 files changed, 35 insertions(+) diff --git a/README b/README index 29a1e157ad..136b537c7d 100644 --- a/README +++ b/README @@ -1133,6 +1133,32 @@ welcome: nickname of a user account that sends welcome messages to new busy servers it may be a good idea to keep that one just for 'urgent' messages. Default is null; no message. +snapshot +-------- + +The software will, by default, send statistical snapshots about the +local installation to a stats server on the laconi.ca Web site. This +data is used by the developers to prioritize development decisions. No +identifying data about users or organizations is collected. The data +is available to the public for review. Participating in this survey +helps Laconica developers take your needs into account when updating +the software. + +run: string indicating when to run the statistics. Values can be 'web' + (run occasionally at Web time), 'cron' (run from a cron script), + or 'never' (don't ever run). If you set it to 'cron', remember to + schedule the script to run on a regular basis. +frequency: if run value is 'web', how often to report statistics. + Measured in Web hits; depends on how active your site is. + Default is 10000 -- that is, one report every 10000 Web hits, + on average. +reporturl: URL to post statistics to. Defaults to Laconica developers' + report system, but if they go evil or disappear you may + need to update this to another value. Note: if you + don't want to report stats, it's much better to + set 'run' to 'never' than to set this value to something + nonsensical. + Troubleshooting =============== diff --git a/config.php.sample b/config.php.sample index 4f438dc5e1..282826a7fb 100644 --- a/config.php.sample +++ b/config.php.sample @@ -206,3 +206,12 @@ $config['sphinx']['port'] = 3312; // print "Error\n"; // exit(1); // } + +// How often to send snapshots; in # of web hits. Ideally, +// try to do this once per month (that is, make this equal to number +// of hits per month) +// $config['snapshot']['frequency'] = 10000; +// If you don't want to report statistics to the central server, uncomment. +// $config['snapshot']['run'] = 'never'; +// If you want to report statistics in a cron job instead. +// $config['snapshot']['run'] = 'cron'; From 2772b0f7ce2878510d7b4f0ea0524ca6ef4f1be1 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 16 Apr 2009 10:17:58 -0700 Subject: [PATCH 08/35] script to report stats from a cron job --- scripts/reportsnapshot.php | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 scripts/reportsnapshot.php diff --git a/scripts/reportsnapshot.php b/scripts/reportsnapshot.php new file mode 100644 index 0000000000..7b7724b9bb --- /dev/null +++ b/scripts/reportsnapshot.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +. + */ + +# Abort if called from a web server +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(1); +} + +ini_set("max_execution_time", "0"); +ini_set("max_input_time", "0"); +set_time_limit(0); +mb_internal_encoding('UTF-8'); + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('LACONICA', true); + +require_once(INSTALLDIR . '/lib/common.php'); + +// All that setup, just for this! + +Snapshot::check(); \ No newline at end of file From b140bcdee4b1f4c8f2f34a89a9c5c51e7ecfe826 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 23 Apr 2009 03:35:18 -0400 Subject: [PATCH 09/35] Added Snapshot::check() to main function for index.php --- index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.php b/index.php index e24bde9179..3f25e004d7 100644 --- a/index.php +++ b/index.php @@ -65,6 +65,8 @@ function main() { global $user, $action, $config; + Snapshot::check(); + if (!_have_config()) { $msg = sprintf(_("No configuration file found. Try running ". "the installation program first.")); From b118ef633a3c1f3446f01a5b22db8fbfb5e4406a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 22 May 2009 10:03:47 -0400 Subject: [PATCH 10/35] Add Gravity to notice sources --- db/notice_source.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/notice_source.sql b/db/notice_source.sql index 17720028dc..7c31a9af49 100644 --- a/db/notice_source.sql +++ b/db/notice_source.sql @@ -9,6 +9,7 @@ VALUES ('Do','Gnome Do','http://do.davebsd.com/wiki/index.php?title=Microblog_Plugin', now()), ('Facebook','Facebook','http://apps.facebook.com/identica/', now()), ('feed2omb','feed2omb','http://projects.ciarang.com/p/feed2omb/', now()), + ('gravity', 'Gravity', 'http://mobileways.de/gravity', now()), ('Gwibber','Gwibber','http://launchpad.net/gwibber', now()), ('HelloTxt','HelloTxt','http://hellotxt.com/', now()), ('identicatools','Laconica Tools','http://bitbucketlabs.net/laconica-tools/', now()), From ef2a5c794e7fc82d7f19675a6a11af64135ef4ee Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 22 May 2009 16:19:14 +0000 Subject: [PATCH 11/35] Fixed in reply to JS link for Conversation page. Handles nested notices better. --- js/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/util.js b/js/util.js index 31d9eb4f54..2dfaafd768 100644 --- a/js/util.js +++ b/js/util.js @@ -235,10 +235,10 @@ function NoticeHover() { function NoticeReply() { if ($('#notice_data-text').length > 0) { $('#content .notice').each(function() { - var notice = $(this); - $('.notice_reply', $(this)).click(function() { - var nickname = ($('.author .nickname', notice).length > 0) ? $('.author .nickname', notice) : $('.author .nickname'); - NoticeReplySet(nickname.text(), $('.notice_id', notice).text()); + var notice = $(this)[0]; + $($('.notice_reply', notice)[0]).click(function() { + var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname'); + NoticeReplySet(nickname.text(), $($('.notice_id', notice)[0]).text()); return false; }); }); From 456f3eeb50fc1cafaa66ab5c0bdcdcaa5ca4bcd0 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 22 May 2009 16:38:06 +0000 Subject: [PATCH 12/35] Removed unnecessary link to base stylesheet because default stylesheet calls base in 0.8.x --- install.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.php b/install.php index bc82e5e37a..1d411c2218 100644 --- a/install.php +++ b/install.php @@ -295,13 +295,13 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" Install Laconica - + - - - + + +
From 7e0a314768fed3c5964e9d404d33a243277559ce Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 24 May 2009 01:38:11 +0000 Subject: [PATCH 13/35] Using event bubbling instead of event handling thanks to Ara Pehlivanian http://arapehlivanian.com --- js/util.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/js/util.js b/js/util.js index 2dfaafd768..baa3f119ef 100644 --- a/js/util.js +++ b/js/util.js @@ -203,7 +203,6 @@ $(document).ready(function(){ $("#notices_primary .notices").prepend(document._importNode(li, true)); $("#notices_primary .notice:first").css({display:"none"}); $("#notices_primary .notice:first").fadeIn(2500); - NoticeHover(); NoticeReply(); } } @@ -221,17 +220,16 @@ $(document).ready(function(){ NoticeReply(); }); + function NoticeHover() { - $("#content .notice").hover( - function () { - $(this).addClass('hover'); - }, - function () { - $(this).removeClass('hover'); - } - ); + function mouseHandler(e) { + $(e.target).closest('li.hentry')[(e.type === 'mouseover') ? 'addClass' : 'removeClass']('hover'); + }; + $('#content .notices').mouseover(mouseHandler); + $('#content .notices').mouseout(mouseHandler); } + function NoticeReply() { if ($('#notice_data-text').length > 0) { $('#content .notice').each(function() { From fde9b09435f6d7fc6cb3f8ccc37dcb3f5ccdb056 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 24 May 2009 01:53:08 +0000 Subject: [PATCH 14/35] Changing opacity to 1 only on the hovered notice item --- theme/default/css/display.css | 4 +++- theme/identica/css/display.css | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/theme/default/css/display.css b/theme/default/css/display.css index 16c9322a5d..bc6bd2ee4e 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -193,7 +193,9 @@ background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-r } .notices div.entry-content, -.notices div.notice-options { +.notices div.notice-options, +.notices li.hover .notices div.entry-content, +.notices li.hover .notices div.notice-options { opacity:0.4; } .notices li.hover div.entry-content, diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 2fb123a20a..b181d90565 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -193,7 +193,9 @@ background:transparent url(../../base/images/icons/twotone/green/trash.gif) no-r } .notices div.entry-content, -.notices div.notice-options { +.notices div.notice-options, +.notices li.hover .notices div.entry-content, +.notices li.hover .notices div.notice-options { opacity:0.4; } .notices li.hover div.entry-content, From b5ac6e31f2f148164860aeabec6899b75d7292ec Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 04:43:34 -0400 Subject: [PATCH 15/35] Rearranged attachment info to only appear on each applicable notice page and thru an ajax popup. --- actions/attachment.php | 10 +++---- actions/attachment_ajax.php | 24 +--------------- actions/attachments.php | 2 -- actions/tag.php | 4 +-- js/util.js | 7 +++-- lib/attachmentlist.php | 6 +--- lib/noticelist.php | 57 +++++++++++++++++-------------------- lib/router.php | 15 ++++++++-- theme/base/css/display.css | 20 ++++++++++++- 9 files changed, 69 insertions(+), 76 deletions(-) diff --git a/actions/attachment.php b/actions/attachment.php index b9187ff081..c51c751200 100644 --- a/actions/attachment.php +++ b/actions/attachment.php @@ -31,8 +31,6 @@ if (!defined('LACONICA')) { exit(1); } -//require_once INSTALLDIR.'/lib/personalgroupnav.php'; -//require_once INSTALLDIR.'/lib/feedlist.php'; require_once INSTALLDIR.'/lib/attachmentlist.php'; /** @@ -67,11 +65,11 @@ class AttachmentAction extends Action { parent::prepare($args); - $id = $this->arg('attachment'); + if ($id = $this->trimmed('attachment')) { + $this->attachment = File::staticGet($id); + } - $this->attachment = File::staticGet($id); - - if (!$this->attachment) { + if (empty($this->attachment)) { $this->clientError(_('No such attachment.'), 404); return false; } diff --git a/actions/attachment_ajax.php b/actions/attachment_ajax.php index 1620b27dda..6930dc112d 100644 --- a/actions/attachment_ajax.php +++ b/actions/attachment_ajax.php @@ -45,26 +45,6 @@ require_once INSTALLDIR.'/actions/attachment.php'; class Attachment_ajaxAction extends AttachmentAction { - /** - * Load attributes based on database arguments - * - * Loads all the DB stuff - * - * @param array $args $_REQUEST array - * - * @return success flag - */ - - function prepare($args) - { - parent::prepare($args); - if (!$this->attachment) { - $this->clientError(_('No such attachment.'), 404); - return false; - } - return true; - } - /** * Show page, a template method. * @@ -87,7 +67,7 @@ class Attachment_ajaxAction extends AttachmentAction */ function showCore() { - $this->elementStart('div', array('id' => 'core')); + $this->elementStart('div', array('id' => 'ajaxcore')); if (Event::handle('StartShowContentBlock', array($this))) { $this->showContentBlock(); Event::handle('EndShowContentBlock', array($this)); @@ -95,8 +75,6 @@ class Attachment_ajaxAction extends AttachmentAction $this->elementEnd('div'); } - - /** * Last-modified date for page * diff --git a/actions/attachments.php b/actions/attachments.php index 6b31c839da..d3c90fec29 100644 --- a/actions/attachments.php +++ b/actions/attachments.php @@ -31,8 +31,6 @@ if (!defined('LACONICA')) { exit(1); } -//require_once INSTALLDIR.'/lib/personalgroupnav.php'; -//require_once INSTALLDIR.'/lib/feedlist.php'; require_once INSTALLDIR.'/lib/attachmentlist.php'; /** diff --git a/actions/tag.php b/actions/tag.php index 47420e4c33..e71ec06a8f 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -49,8 +49,8 @@ class TagAction extends Action { $pop = new PopularNoticeSection($this); $pop->show(); - $freqatt = new FrequentAttachmentSection($this); - $freqatt->show(); +// $freqatt = new FrequentAttachmentSection($this); +// $freqatt->show(); } function title() diff --git a/js/util.js b/js/util.js index 2dfaafd768..4f2b036fa4 100644 --- a/js/util.js +++ b/js/util.js @@ -17,9 +17,10 @@ */ $(document).ready(function(){ - $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); - }, url:$(this).attr('href') + '/ajax'}); return false; }); - $('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); +// attachments and attachment pages not used at the moment except for attachment_ajax version +// $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); +// }, url:$(this).attr('href') + '/ajax'}); return false; }); + $('.attachment').click(function() {$().jOverlay({url:'http://laptop.waglo.com/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); // count character on keyup function counter(event){ diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 9485fe3d65..1be7b2fee9 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -191,7 +191,7 @@ class AttachmentListItem extends Widget } function linkAttr() { - return array('class' => 'attachment', 'href' => common_local_url('attachment', array('attachment' => $this->attachment->id))); + return array('class' => 'attachment', 'href' => $this->attachment->url, 'id' => 'attachment-' . $this->attachment->id); } function showLink() { @@ -200,10 +200,6 @@ class AttachmentListItem extends Widget $this->out->elementStart('h4'); $this->out->element('a', $attr, $text); - if ($this->attachment->url !== $this->title()) - $this->out->element('span', null, " ({$this->attachment->url})"); - - $this->out->elementEnd('h4'); } diff --git a/lib/noticelist.php b/lib/noticelist.php index a521321719..e3361fc99e 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -34,6 +34,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR.'/lib/favorform.php'; require_once INSTALLDIR.'/lib/disfavorform.php'; +require_once INSTALLDIR.'/lib/attachmentlist.php'; /** * widget for displaying a list of notices @@ -179,9 +180,10 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); - $this->showNoticeAttachments(); + $this->showNoticeAttachmentsIcon(); $this->showNoticeInfo(); $this->showNoticeOptions(); + $this->showNoticeAttachments(); $this->showEnd(); } @@ -193,45 +195,38 @@ class NoticeListItem extends Widget $this->out->elementEnd('div'); } - function showNoticeAttachments() - { + function showNoticeAttachments() { + if ($this->isUsedInList()) { + return; + } + $al = new AttachmentList($this->notice, $this->out); + $al->show(); + } + + function isUsedInList() { + return 'shownotice' !== $this->out->args['action']; + } + + function attachmentCount() { $f2p = new File_to_post; $f2p->post_id = $this->notice->id; $file = new File; $file->joinAdd($f2p); $file->selectAdd(); $file->selectAdd('file.id as id'); - $count = $file->find(true); - if (!$count) return; - if (1 === $count) { - $href = common_local_url('attachment', array('attachment' => $file->id)); - $att_class = 'attachment'; - } else { - $href = common_local_url('attachments', array('notice' => $this->notice->id)); - $att_class = 'attachments'; + return $file->find(true); + } + + function showNoticeAttachmentsIcon() + { + if (!($this->isUsedInList() && ($count = $this->attachmentCount()))) { + return; } - $clip = theme_path('images/icons/clip', 'base'); - if ('shownotice' === $this->out->args['action']) { - $height = '96px'; - $width = '83%'; - $width_att = '15%'; - $clip .= '-big.png'; - $top = '70px'; - } else { - $height = '48px'; - $width = '90%'; - $width_att = '8%'; - $clip .= '.png'; - $top = '20px'; - } -if(0) - $this->out->elementStart('div', 'entry-attachments'); -else - $this->out->elementStart('p', array('class' => 'entry-attachments', 'style' => "float: right; width: $width_att; background: url($clip) no-repeat; text-align: right; height: $height;")); - $this->out->element('a', array('class' => $att_class, 'style' => "text-decoration: none; padding-top: $top; display: block; height: $height;", 'href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); - + $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; + $this->out->elementStart('p', 'entry-attachments'); + $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); $this->out->elementEnd('p'); } diff --git a/lib/router.php b/lib/router.php index 70ee0f3fb0..39c005609e 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,26 +151,35 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); +/* + $m->connect('attachment/ajax_by_url/*url', + array('action' => 'attachment_ajax')); +*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), - array('notice' => '[0-9]+')); + array('attachment' => '[0-9]+')); +/* + TODO + not used right now, will revisit later $m->connect('attachment/:attachment', array('action' => 'attachment'), - array('notice' => '[0-9]+')); - + array('attachment' => '[0-9]+')); +*/ // notice $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); +/* $m->connect('notice/:notice/attachments/ajax', array('action' => 'attachments_ajax'), array('notice' => '[0-9]+')); $m->connect('notice/:notice/attachments', array('action' => 'attachments'), array('notice' => '[0-9]+')); +*/ $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 5d2b5231c9..cb4680c39a 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -379,6 +379,12 @@ max-width:1003px; overflow:hidden; } +#ajaxcore { +width: 520px; +height: 600px; +background: #fff; +} + #core { position:relative; width:100%; @@ -1048,8 +1054,20 @@ margin-bottom:18px; margin-left:18px; } +p.entry-attachments { +float: right; +width: 8%; +background: url(../images/icons/clip.png) no-repeat; +text-align: right; +height: 48px; +} - +p.entry-attachments a { +text-decoration: none; +padding-top: 20px; +display: block; +height: 48px; +} /* TOP_POSTERS */ .section tbody td { From 07dabe7889c566e1cd73c8e4c6b7b84af77e5b9f Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Sun, 24 May 2009 21:16:26 +0000 Subject: [PATCH 16/35] Made conversation thread UI a bit more visible. Added right margin for notice options. --- theme/base/css/display.css | 17 +++++------------ theme/default/css/display.css | 10 +++++----- theme/identica/css/display.css | 10 +++++----- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index cb4680c39a..8f72460a80 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -748,15 +748,10 @@ border-top-style:dotted; .notices li { list-style-type:none; } -.notices li.hover { -border-radius:4px; --moz-border-radius:4px; --webkit-border-radius:4px; -} .notices .notices { margin-top:7px; -margin-left:3%; -width:97%; +margin-left:5%; +width:95%; float:left; } @@ -833,7 +828,7 @@ clear:left; float:left; font-size:0.95em; margin-left:59px; -width:65%; +width:60%; } #showstream .notice div.entry-content, #shownotice .notice div.entry-content { @@ -865,13 +860,11 @@ text-transform:lowercase; .notice-options { -padding-left:2%; -float:left; -width:50%; position:relative; font-size:0.95em; -width:12.5%; +width:90px; float:right; +margin-right:11px; } .notice-options a { diff --git a/theme/default/css/display.css b/theme/default/css/display.css index bc6bd2ee4e..737db7ce96 100644 --- a/theme/default/css/display.css +++ b/theme/default/css/display.css @@ -214,16 +214,16 @@ background-color:#fcfcfc; } .notices .notices { -background-color:rgba(200, 200, 200, 0.025); -} -.notices .notices .notices { background-color:rgba(200, 200, 200, 0.050); } +.notices .notices .notices { +background-color:rgba(200, 200, 200, 0.100); +} .notices .notices .notices .notices { -background-color:rgba(200, 200, 200, 0.075); +background-color:rgba(200, 200, 200, 0.150); } .notices .notices .notices .notices .notices { -background-color:rgba(200, 200, 200, 0.100); +background-color:rgba(200, 200, 200, 0.300); } /*END: NOTICES */ diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index b181d90565..f7abac4823 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -214,16 +214,16 @@ background-color:#fcfcfc; } .notices .notices { -background-color:rgba(200, 200, 200, 0.025); -} -.notices .notices .notices { background-color:rgba(200, 200, 200, 0.050); } +.notices .notices .notices { +background-color:rgba(200, 200, 200, 0.100); +} .notices .notices .notices .notices { -background-color:rgba(200, 200, 200, 0.075); +background-color:rgba(200, 200, 200, 0.150); } .notices .notices .notices .notices .notices { -background-color:rgba(200, 200, 200, 0.100); +background-color:rgba(200, 200, 200, 0.300); } /*END: NOTICES */ From bd70caace84758e6655f8db4957049492834a6c6 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 18:06:19 -0400 Subject: [PATCH 17/35] Only show number of attachments if > 1 --- lib/noticelist.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/noticelist.php b/lib/noticelist.php index e3361fc99e..51b8987fe9 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -207,14 +207,12 @@ class NoticeListItem extends Widget return 'shownotice' !== $this->out->args['action']; } - function attachmentCount() { - $f2p = new File_to_post; - $f2p->post_id = $this->notice->id; - $file = new File; - $file->joinAdd($f2p); - $file->selectAdd(); - $file->selectAdd('file.id as id'); - return $file->find(true); + function attachmentCount($discriminant = true) { + $file_oembed = new File_oembed; + $query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id; + $file_oembed->query($query); + $file_oembed->fetch(); + return intval($file_oembed->c); } function showNoticeAttachmentsIcon() @@ -224,7 +222,6 @@ class NoticeListItem extends Widget } $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; - $this->out->elementStart('p', 'entry-attachments'); $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); $this->out->elementEnd('p'); From b0a891e92b55ea6d3323e8efe528f46afda7c1fc Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 18:40:11 -0400 Subject: [PATCH 18/35] Made ajax link to show attachment popups relative in util.js --- js/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 1b75c5e227..6511c0380d 100644 --- a/js/util.js +++ b/js/util.js @@ -20,7 +20,7 @@ $(document).ready(function(){ // attachments and attachment pages not used at the moment except for attachment_ajax version // $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); // }, url:$(this).attr('href') + '/ajax'}); return false; }); - $('.attachment').click(function() {$().jOverlay({url:'http://laptop.waglo.com/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + $('.attachment').click(function() {$().jOverlay({url:'../attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); // count character on keyup function counter(event){ From 5f3acc252738e408ea2447b7541eae66c1e9e09a Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 21:13:42 -0400 Subject: [PATCH 19/35] Removed big clip and replaced with smaller inline one next to each URL (in a notice) that's actually an attachment. Overlay (popup) on click. --- js/util.js | 6 +++++- lib/noticelist.php | 1 - lib/util.php | 11 +++++++++++ theme/base/images/icons/clip-inline.png | Bin 0 -> 1646 bytes 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 theme/base/images/icons/clip-inline.png diff --git a/js/util.js b/js/util.js index 6511c0380d..b6848abaa2 100644 --- a/js/util.js +++ b/js/util.js @@ -20,7 +20,11 @@ $(document).ready(function(){ // attachments and attachment pages not used at the moment except for attachment_ajax version // $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); // }, url:$(this).attr('href') + '/ajax'}); return false; }); - $('.attachment').click(function() {$().jOverlay({url:'../attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + + //FIXME + //need to link to proper url depending on site config (path name and theme, for instance) + $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + $('.entry-title a.attachment').append(' Attachment'); // count character on keyup function counter(event){ diff --git a/lib/noticelist.php b/lib/noticelist.php index 51b8987fe9..ae14388921 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -180,7 +180,6 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); - $this->showNoticeAttachmentsIcon(); $this->showNoticeInfo(); $this->showNoticeOptions(); $this->showNoticeAttachments(); diff --git a/lib/util.php b/lib/util.php index fbef8764a7..4a55cbfe59 100644 --- a/lib/util.php +++ b/lib/util.php @@ -496,6 +496,17 @@ function common_linkify($url) { } $attrs = array('href' => $longurl, 'rel' => 'external'); + +// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' +// where ID is the id of the attachment for the given URL. + $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; + $file = new File; + $file->query($query); + $file->fetch(); + if (!empty($file->file_id)) { + $attrs['class'] = 'attachment'; + $attrs['id'] = "attachment-{$file->file_id}"; + } return XMLStringer::estring('a', $attrs, $display); } diff --git a/theme/base/images/icons/clip-inline.png b/theme/base/images/icons/clip-inline.png new file mode 100644 index 0000000000000000000000000000000000000000..870f8b2e8ff32f1b5e19a9a2389648bfdfd47ec9 GIT binary patch literal 1646 zcmV-!29f!RP)71Q{00004b3#c}2nYxW zd95B}{OcTWhu4z*Pi$1#~vVrphs~40I$efG23$1a(&&Fb+O8)mEZW0{~4pk z__m|bQSWxUy@U_~j{?kImQAnxVC8fcba*cxys&d7ZYbBCe`)Uxu6;@$+CP#6ve)n*qFyw?Oyf!g-)k-Orhh-V|d z>OI)I7C#_{3yv1NrSs`d(3k0vv3X+)E`58cg|^ZfilRyf2M7DDR%?L#^O{gkQ_saD zMN+4z6gN`;7t39r8?jBh?O>z1adDzAG1w8)q4FQ_pT{!R`20Sj*XwnY39%7E2mtuv zmGP%!mAwAGK>&aqpX_)n?$x-eZew>aIU!l4AJ98-J-z@4Gyu@;^?JuiSd9Qcfe->V zf_

7o0oApk((p~9tYr0poajCs5eryGwN+i8xzCwMsSwl3RNoT>09>Fg*xJB1yg#FVhM!Gl)q}-@4LE=+7>22_*=$Zih&=I5 z?#A4R)YnoEIj%dNQecIuwzAd`(HCI|g+j;f3g&LijYxSd<&ep2nwKCX#I@XLp+XfQ zgCt0rU@+J=Iy&l^7$E?_ho60z$R%>WcubxkPQd9cWi3}Jo~l$R6sPTW`{a=V0POm5 z*GzM~xr+UR})KN@bqdZ=uz1VVR3rx`C2#CLsb((P7MtWv4jvY?2clm zW@kZ%tK*I7*Qe80$dwpRna2PkXfehHmSt~s?rk6dDDpM=+bjAiwuF8RH9xocIZTcgoz5HKV?rT>5MaQ0rFlP;|5Of!ydB?uaq0Y6jK!Z{?OpT>jZ zmmLm=C;U~nfwN}KimbEMtyQ)u&k#Z?IgT47gviOs$wGEYHj=WWZ00J{qf)87oAWo% z$t=h`V(Yg-;BeF%~bRAQ>IN>wB*Gl^Sk1^W_k8|sws)m5=5Ff zjvEQzGYiX7{>)ot%XKT-jPz@&$L0XAOCZ6ZV?iJx3 zAPEt-a+;EoN99NWfbi|H>)@`mZe{n$s^Y3P%0gWhMe)pJ%ldu~ Date: Mon, 25 May 2009 11:13:13 -0400 Subject: [PATCH 20/35] Display thumbnail on hover over links in notices when appropriate. --- js/util.js | 13 +++++++++++++ lib/attachmentlist.php | 4 ++-- lib/router.php | 4 ++++ lib/util.php | 12 +++++++++++- theme/base/css/display.css | 8 ++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/js/util.js b/js/util.js index b6848abaa2..9ee2a19635 100644 --- a/js/util.js +++ b/js/util.js @@ -25,6 +25,19 @@ $(document).ready(function(){ //need to link to proper url depending on site config (path name and theme, for instance) $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); $('.entry-title a.attachment').append(' Attachment'); + $('a.thumbnail').hover(function() { + anchor = $(this); + $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + $('#thumbnail').fadeIn('def'); + }); + }, + function() { + setTimeout(function() { + $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); + }, 500); + } + ); // count character on keyup function counter(event){ diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 1be7b2fee9..52aa5d9ee5 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -171,7 +171,7 @@ class AttachmentListItem extends Widget } function linkTitle() { - return 'Our page for ' . $this->title(); + return $this->title(); } /** @@ -256,7 +256,7 @@ class Attachment extends AttachmentListItem } function linkTitle() { - return 'Direct link to ' . $this->title(); + return $this->attachment->url; } function showRepresentation() { diff --git a/lib/router.php b/lib/router.php index 39c005609e..d1e2970c5f 100644 --- a/lib/router.php +++ b/lib/router.php @@ -159,6 +159,10 @@ class Router array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); + $m->connect('attachment/:attachment/thumbnail', + array('action' => 'attachment_thumbnail'), + array('attachment' => '[0-9]+')); + /* TODO not used right now, will revisit later diff --git a/lib/util.php b/lib/util.php index 4a55cbfe59..d56f44f7b4 100644 --- a/lib/util.php +++ b/lib/util.php @@ -503,8 +503,18 @@ function common_linkify($url) { $file = new File; $file->query($query); $file->fetch(); + if (!empty($file->file_id)) { - $attrs['class'] = 'attachment'; + $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; + $file2 = new File; + $file2->query($query); + $file2->fetch(); + + if (empty($file2->file_id)) { + $attrs['class'] = 'attachment'; + } else { + $attrs['class'] = 'attachment thumbnail'; + } $attrs['id'] = "attachment-{$file->file_id}"; } return XMLStringer::estring('a', $attrs, $display); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 8f72460a80..71a434c542 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1205,3 +1205,11 @@ display:none; .guide { clear:both; } + +#thumbnail { +position:absolute; +z-index: 999; +display: none; +left: 100px; +} + From 01ce677ae399874e81dc21991faf821a539fa00a Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 16:49:32 +0000 Subject: [PATCH 21/35] Small bugfix to installer fixing fancy URL detection. --- index.php | 2 +- install.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 9ff1c2c56a..c2972ec5fe 100644 --- a/index.php +++ b/index.php @@ -64,7 +64,7 @@ function handleError($error) function main() { // quick check for fancy URL auto-detection support in installer. - if (isset($_SERVER['REDIRECT_URL']) && ('/check-fancy' === $_SERVER['REDIRECT_URL'])) { + if (isset($_SERVER['REDIRECT_URL']) && ((dirname($_SERVER['REQUEST_URI']) . '/check-fancy') === $_SERVER['REDIRECT_URL'])) { die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs."); } global $user, $action, $config; diff --git a/install.php b/install.php index 1d411c2218..133f2b30f6 100644 --- a/install.php +++ b/install.php @@ -116,16 +116,16 @@ function showForm() disable

Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

-
  • - - -

    Database hostname

    -
  • Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.

  • +
  • + + +

    Database hostname

    +
  • From 0b96ca3d5957a0cb363813fe44cc1865bb6c4eb5 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 13:13:38 -0400 Subject: [PATCH 22/35] Oups, forget the attachment_thumbnail.php action file --- actions/attachment_thumbnail.php | 127 +++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 actions/attachment_thumbnail.php diff --git a/actions/attachment_thumbnail.php b/actions/attachment_thumbnail.php new file mode 100644 index 0000000000..32fab13242 --- /dev/null +++ b/actions/attachment_thumbnail.php @@ -0,0 +1,127 @@ +. + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/actions/attachment.php'; + +/** + * Show notice attachments + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class Attachment_thumbnailAction extends AttachmentAction +{ + /** + * Show page, a template method. + * + * @return nothing + */ + function showPage() + { + if (Event::handle('StartShowBody', array($this))) { + $this->showCore(); + Event::handle('EndShowBody', array($this)); + } + } + + /** + * Show core. + * + * Shows local navigation, content block and aside. + * + * @return nothing + */ + function showCore() + { + $file_thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id); + if (empty($file_thumbnail->url)) { + return; + } + $url = $file_thumbnail->url; + + $attr = array( + 'id' => 'thumbnail' + , 'src' => $url + , 'alt' => 'Thumbnail' + ); + + $this->element('img', $attr); + + } + + /** + * Last-modified date for page + * + * When was the content of this page last modified? Based on notice, + * profile, avatar. + * + * @return int last-modified date as unix timestamp + */ +/* + function lastModified() + { + return max(strtotime($this->notice->created), + strtotime($this->profile->modified), + ($this->avatar) ? strtotime($this->avatar->modified) : 0); + } +*/ + + /** + * An entity tag for this page + * + * Shows the ETag for the page, based on the notice ID and timestamps + * for the notice, profile, and avatar. It's weak, since we change + * the date text "one hour ago", etc. + * + * @return string etag + */ +/* + function etag() + { + $avtime = ($this->avatar) ? + strtotime($this->avatar->modified) : 0; + + return 'W/"' . implode(':', array($this->arg('action'), + common_language(), + $this->notice->id, + strtotime($this->notice->created), + strtotime($this->profile->modified), + $avtime)) . '"'; + } +*/ +} + From 7923e84fba66d8e3e7ec24a8a663f0c2c0f0e533 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 25 May 2009 18:54:45 +0000 Subject: [PATCH 23/35] Fixed URL for attachment thumbnail and XHR --- js/util.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/util.js b/js/util.js index 9ee2a19635..ffaedc690d 100644 --- a/js/util.js +++ b/js/util.js @@ -23,20 +23,20 @@ $(document).ready(function(){ //FIXME //need to link to proper url depending on site config (path name and theme, for instance) - $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); - $('.entry-title a.attachment').append(' Attachment'); - $('a.thumbnail').hover(function() { - anchor = $(this); - $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { - anchor.append(data); - $('#thumbnail').fadeIn('def'); - }); - }, - function() { - setTimeout(function() { - $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); - }, 500); - } + $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + $('a.thumbnail').hover( + function() { + anchor = $(this); + $.get($('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + $('#thumbnail').fadeIn('def'); + }); + }, + function() { + setTimeout(function() { + $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); + }, 500); + } ); // count character on keyup From b22980586199a35a9800d9ff1ace6d1c6e9bf205 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 25 May 2009 15:02:28 -0400 Subject: [PATCH 24/35] Resetting some of the attachment styles. Will update in the next commit. --- theme/base/css/display.css | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 71a434c542..74f3691425 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -379,12 +379,6 @@ max-width:1003px; overflow:hidden; } -#ajaxcore { -width: 520px; -height: 600px; -background: #fff; -} - #core { position:relative; width:100%; @@ -858,6 +852,16 @@ display:inline-block; text-transform:lowercase; } +.notice .attachment { +position:relative; +} +.notice .attachment img { +position:absolute; +top:11px; +left:0; +z-index:99; +} + .notice-options { position:relative; @@ -1047,20 +1051,6 @@ margin-bottom:18px; margin-left:18px; } -p.entry-attachments { -float: right; -width: 8%; -background: url(../images/icons/clip.png) no-repeat; -text-align: right; -height: 48px; -} - -p.entry-attachments a { -text-decoration: none; -padding-top: 20px; -display: block; -height: 48px; -} /* TOP_POSTERS */ .section tbody td { @@ -1205,11 +1195,3 @@ display:none; .guide { clear:both; } - -#thumbnail { -position:absolute; -z-index: 999; -display: none; -left: 100px; -} - From 594454ced3d02ceb766bdbdce1dbfa871abec464 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 15:38:50 -0400 Subject: [PATCH 25/35] Single anchor to include thumbnail and title for attachment --- lib/attachmentlist.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 52aa5d9ee5..2a0114b127 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -198,23 +198,22 @@ class AttachmentListItem extends Widget $attr = $this->linkAttr(); $text = $this->linkTitle(); $this->out->elementStart('h4'); - $this->out->element('a', $attr, $text); - + $this->out->elementStart('a', $attr); + $this->out->element('span', null, $text); + $this->showRepresentation(); + $this->out->elementEnd('a'); $this->out->elementEnd('h4'); } function showNoticeAttachment() { $this->showLink(); - $this->showRepresentation(); } function showRepresentation() { $thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id); if (!empty($thumbnail)) { - $this->out->elementStart('a', $this->linkAttr()/*'href' => $this->linkTo()*/); $this->out->element('img', array('alt' => 'nothing to say', 'src' => $thumbnail->url, 'width' => $thumbnail->width, 'height' => $thumbnail->height)); - $this->out->elementEnd('a'); } } From 64d0767654d93de81a0779f04eb992c574bbdece Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 19:42:03 +0000 Subject: [PATCH 26/35] Removed more cruft from old attachment/attachements pages --- actions/tag.php | 2 -- lib/router.php | 22 +--------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/actions/tag.php b/actions/tag.php index e71ec06a8f..e9351d2419 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -49,8 +49,6 @@ class TagAction extends Action { $pop = new PopularNoticeSection($this); $pop->show(); -// $freqatt = new FrequentAttachmentSection($this); -// $freqatt->show(); } function title() diff --git a/lib/router.php b/lib/router.php index d1e2970c5f..fc119821b9 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,10 +151,6 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); -/* - $m->connect('attachment/ajax_by_url/*url', - array('action' => 'attachment_ajax')); -*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); @@ -163,27 +159,11 @@ class Router array('action' => 'attachment_thumbnail'), array('attachment' => '[0-9]+')); -/* - TODO - not used right now, will revisit later - $m->connect('attachment/:attachment', - array('action' => 'attachment'), - array('attachment' => '[0-9]+')); -*/ - // notice - $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); -/* - $m->connect('notice/:notice/attachments/ajax', - array('action' => 'attachments_ajax'), - array('notice' => '[0-9]+')); - $m->connect('notice/:notice/attachments', - array('action' => 'attachments'), - array('notice' => '[0-9]+')); -*/ + $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); From 01dad5729827870d87f87118c336dcf2acc4af32 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 25 May 2009 15:53:19 -0400 Subject: [PATCH 27/35] Markup cleanup for attachments --- actions/attachment.php | 2 -- actions/attachment_ajax.php | 2 +- js/util.js | 6 ------ lib/attachmentlist.php | 17 +++++++---------- lib/noticelist.php | 14 +------------- theme/base/css/display.css | 3 +++ 6 files changed, 12 insertions(+), 32 deletions(-) diff --git a/actions/attachment.php b/actions/attachment.php index c51c751200..16ee723d96 100644 --- a/actions/attachment.php +++ b/actions/attachment.php @@ -176,10 +176,8 @@ class AttachmentAction extends Action function showContent() { - $this->elementStart('ul', array('class' => 'attachments')); $ali = new Attachment($this->attachment, $this); $cnt = $ali->show(); - $this->elementEnd('ul'); } /** diff --git a/actions/attachment_ajax.php b/actions/attachment_ajax.php index 6930dc112d..3d83393c51 100644 --- a/actions/attachment_ajax.php +++ b/actions/attachment_ajax.php @@ -67,7 +67,7 @@ class Attachment_ajaxAction extends AttachmentAction */ function showCore() { - $this->elementStart('div', array('id' => 'ajaxcore')); + $this->elementStart('div', array('id' => 'core')); if (Event::handle('StartShowContentBlock', array($this))) { $this->showContentBlock(); Event::handle('EndShowContentBlock', array($this)); diff --git a/js/util.js b/js/util.js index ffaedc690d..cba6f822eb 100644 --- a/js/util.js +++ b/js/util.js @@ -17,12 +17,6 @@ */ $(document).ready(function(){ -// attachments and attachment pages not used at the moment except for attachment_ajax version -// $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); -// }, url:$(this).attr('href') + '/ajax'}); return false; }); - - //FIXME - //need to link to proper url depending on site config (path name and theme, for instance) $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); $('a.thumbnail').hover( function() { diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 2a0114b127..d0478bad35 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -80,9 +80,9 @@ class AttachmentList extends Widget function show() { -// $this->out->elementStart('div', array('id' =>'attachments_primary')); - $this->out->elementStart('div', array('id' =>'content')); - $this->out->element('h2', null, _('Attachments')); + $this->out->elementStart('dl', array('id' =>'attachment')); + $this->out->element('dt', null, _('Attachments')); + $this->out->elementStart('dd'); $this->out->elementStart('ul', array('class' => 'attachments')); $atts = new File; @@ -92,8 +92,9 @@ class AttachmentList extends Widget $item->show(); } + $this->out->elementEnd('dd'); $this->out->elementEnd('ul'); - $this->out->elementEnd('div'); + $this->out->elementEnd('dl'); return count($att); } @@ -195,14 +196,10 @@ class AttachmentListItem extends Widget } function showLink() { - $attr = $this->linkAttr(); - $text = $this->linkTitle(); - $this->out->elementStart('h4'); - $this->out->elementStart('a', $attr); - $this->out->element('span', null, $text); + $this->out->elementStart('a', $this->linkAttr()); + $this->out->element('span', null, $this->linkTitle()); $this->showRepresentation(); $this->out->elementEnd('a'); - $this->out->elementEnd('h4'); } function showNoticeAttachment() diff --git a/lib/noticelist.php b/lib/noticelist.php index ae14388921..50a95cfcbb 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -180,9 +180,9 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); + $this->showNoticeAttachments(); $this->showNoticeInfo(); $this->showNoticeOptions(); - $this->showNoticeAttachments(); $this->showEnd(); } @@ -214,18 +214,6 @@ class NoticeListItem extends Widget return intval($file_oembed->c); } - function showNoticeAttachmentsIcon() - { - if (!($this->isUsedInList() && ($count = $this->attachmentCount()))) { - return; - } - - $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; - $this->out->elementStart('p', 'entry-attachments'); - $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); - $this->out->elementEnd('p'); - } - function showNoticeInfo() { $this->out->elementStart('div', 'entry-content'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 74f3691425..aa76910f0b 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -861,6 +861,9 @@ top:11px; left:0; z-index:99; } +#shownotice .notice .attachment img { +position:static; +} .notice-options { From a598dcccba21daa6decefb7fb38882c1e77904eb Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 19:58:31 +0000 Subject: [PATCH 28/35] Really removing the old files, thanks git! --- actions/attachments.php | 290 ------------------------------ actions/attachments_ajax.php | 115 ------------ lib/attachmentsection.php | 80 --------- lib/frequentattachmentsection.php | 66 ------- 4 files changed, 551 deletions(-) delete mode 100644 actions/attachments.php delete mode 100644 actions/attachments_ajax.php delete mode 100644 lib/attachmentsection.php delete mode 100644 lib/frequentattachmentsection.php diff --git a/actions/attachments.php b/actions/attachments.php deleted file mode 100644 index d3c90fec29..0000000000 --- a/actions/attachments.php +++ /dev/null @@ -1,290 +0,0 @@ -. - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/attachmentlist.php'; - -/** - * Show notice attachments - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class AttachmentsAction extends Action -{ - /** - * Notice object to show - */ - - var $notice = null; - - /** - * Profile of the notice object - */ - - var $profile = null; - - /** - * Avatar of the profile of the notice object - */ - - var $avatar = null; - - /** - * Is this action read-only? - * - * @return boolean true - */ - - function isReadOnly($args) - { - return true; - } - - /** - * Last-modified date for page - * - * When was the content of this page last modified? Based on notice, - * profile, avatar. - * - * @return int last-modified date as unix timestamp - */ - - function lastModified() - { - return max(strtotime($this->notice->created), - strtotime($this->profile->modified), - ($this->avatar) ? strtotime($this->avatar->modified) : 0); - } - - /** - * An entity tag for this page - * - * Shows the ETag for the page, based on the notice ID and timestamps - * for the notice, profile, and avatar. It's weak, since we change - * the date text "one hour ago", etc. - * - * @return string etag - */ - - function etag() - { - $avtime = ($this->avatar) ? - strtotime($this->avatar->modified) : 0; - - return 'W/"' . implode(':', array($this->arg('action'), - common_language(), - $this->notice->id, - strtotime($this->notice->created), - strtotime($this->profile->modified), - $avtime)) . '"'; - } - - /** - * Title of the page - * - * @return string title of the page - */ - - function title() - { - return sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, - common_exact_date($this->notice->created)); - } - - - /** - * Load attributes based on database arguments - * - * Loads all the DB stuff - * - * @param array $args $_REQUEST array - * - * @return success flag - */ - - function prepare($args) - { - parent::prepare($args); - - $id = $this->arg('notice'); - - $this->notice = Notice::staticGet($id); - - if (!$this->notice) { - $this->clientError(_('No such notice.'), 404); - return false; - } - - -/* -// STOP if there are no attachments -// maybe even redirect if there's a single one -// RYM FIXME TODO - $this->clientError(_('No such attachment.'), 404); - return false; - -*/ - - - - - $this->profile = $this->notice->getProfile(); - - if (!$this->profile) { - $this->serverError(_('Notice has no profile'), 500); - return false; - } - - $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); - return true; - } - - - - /** - * Handle input - * - * Only handles get, so just show the page. - * - * @param array $args $_REQUEST data (unused) - * - * @return void - */ - - function handle($args) - { - parent::handle($args); - - if ($this->notice->is_local == 0) { - if (!empty($this->notice->url)) { - common_redirect($this->notice->url, 301); - } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { - common_redirect($this->notice->uri, 301); - } - } else { - $f2p = new File_to_post; - $f2p->post_id = $this->notice->id; - $file = new File; - $file->joinAdd($f2p); - $file->selectAdd(); - $file->selectAdd('file.id as id'); - $count = $file->find(true); - if (!$count) return; - if (1 === $count) { - common_redirect(common_local_url('attachment', array('attachment' => $file->id)), 301); - } else { - $this->showPage(); - } - } - } - - /** - * Don't show local navigation - * - * @return void - */ - - function showLocalNavBlock() - { - } - - /** - * Fill the content area of the page - * - * Shows a single notice list item. - * - * @return void - */ - - function showContent() - { - $al = new AttachmentList($this->notice, $this); - $cnt = $al->show(); - } - - /** - * Don't show page notice - * - * @return void - */ - - function showPageNoticeBlock() - { - } - - /** - * Don't show aside - * - * @return void - */ - - function showAside() { - } - - /** - * Extra content - * - * We show the microid(s) for the author, if any. - * - * @return void - */ - - function extraHead() - { - $user = User::staticGet($this->profile->id); - - if (!$user) { - return; - } - - if ($user->emailmicroid && $user->email && $this->notice->uri) { - $id = new Microid('mailto:'. $user->email, - $this->notice->uri); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - - if ($user->jabbermicroid && $user->jabber && $this->notice->uri) { - $id = new Microid('xmpp:', $user->jabber, - $this->notice->uri); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - } -} - diff --git a/actions/attachments_ajax.php b/actions/attachments_ajax.php deleted file mode 100644 index 402d8b5e79..0000000000 --- a/actions/attachments_ajax.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -//require_once INSTALLDIR.'/lib/personalgroupnav.php'; -//require_once INSTALLDIR.'/lib/feedlist.php'; -require_once INSTALLDIR.'/actions/attachments.php'; - -/** - * Show notice attachments - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class Attachments_ajaxAction extends AttachmentsAction -{ - function showContent() - { - } - - /** - * Fill the content area of the page - * - * Shows a single notice list item. - * - * @return void - */ - - function showContentBlock() - { - $al = new AttachmentList($this->notice, $this); - $cnt = $al->show(); - } - - /** - * Extra content - * - * We show the microid(s) for the author, if any. - * - * @return void - */ - - function extraHead() - { - } - - - /** - * Show page, a template method. - * - * @return nothing - */ - function showPage() - { - if (Event::handle('StartShowBody', array($this))) { - $this->showCore(); - Event::handle('EndShowBody', array($this)); - } - } - - /** - * Show core. - * - * Shows local navigation, content block and aside. - * - * @return nothing - */ - function showCore() - { - $this->elementStart('div', array('id' => 'core')); - if (Event::handle('StartShowContentBlock', array($this))) { - $this->showContentBlock(); - Event::handle('EndShowContentBlock', array($this)); - } - $this->elementEnd('div'); - } - - - - -} - diff --git a/lib/attachmentsection.php b/lib/attachmentsection.php deleted file mode 100644 index 20e620b9b6..0000000000 --- a/lib/attachmentsection.php +++ /dev/null @@ -1,80 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -define('ATTACHMENTS_PER_SECTION', 6); - -/** - * Base class for sections showing lists of attachments - * - * These are the widgets that show interesting data about a person - * group, or site. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class AttachmentSection extends Section -{ - function showContent() - { - $attachments = $this->getAttachments(); - - $cnt = 0; - - $this->out->elementStart('ul', 'attachments'); - - while ($attachments->fetch() && ++$cnt <= ATTACHMENTS_PER_SECTION) { - $this->showAttachment($attachments); - } - - $this->out->elementEnd('ul'); - - return ($cnt > ATTACHMENTS_PER_SECTION); - } - - function getAttachments() - { - return null; - } - - function showAttachment($attachment) - { - $this->out->elementStart('li'); - $this->out->element('a', array('class' => 'attachment', 'href' => common_local_url('attachment', array('attachment' => $attachment->file_id))), "Attachment tagged {$attachment->c} times"); - $this->out->elementEnd('li'); - } -} - diff --git a/lib/frequentattachmentsection.php b/lib/frequentattachmentsection.php deleted file mode 100644 index 0ce0d18714..0000000000 --- a/lib/frequentattachmentsection.php +++ /dev/null @@ -1,66 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -/** - * FIXME - * - * These are the widgets that show interesting data about a person - * group, or site. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class FrequentAttachmentSection extends AttachmentSection -{ - function getAttachments() { - $notice_tag = new Notice_tag; - $query = 'select file_id, count(file_id) as c from notice_tag join file_to_post on post_id = notice_id where tag="' . $notice_tag->escape($this->out->tag) . '" group by file_id order by c desc'; - $notice_tag->query($query); - return $notice_tag; - } - - function title() - { - return sprintf(_('Attachments frequently tagged with %s'), $this->out->tag); - } - - function divId() - { - return 'frequent_attachments'; - } -} - From 3877324fd8ddad36531fb80a5a2ae261015b9780 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 25 May 2009 17:30:57 -0400 Subject: [PATCH 29/35] Updated JS to show/hide attachment thumbnails with timers. Minor markup changes. --- actions/attachment_thumbnail.php | 11 +---------- js/util.js | 26 +++++++++++++++++--------- theme/base/css/display.css | 5 ++++- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/actions/attachment_thumbnail.php b/actions/attachment_thumbnail.php index 32fab13242..b4070e747b 100644 --- a/actions/attachment_thumbnail.php +++ b/actions/attachment_thumbnail.php @@ -71,16 +71,7 @@ class Attachment_thumbnailAction extends AttachmentAction if (empty($file_thumbnail->url)) { return; } - $url = $file_thumbnail->url; - - $attr = array( - 'id' => 'thumbnail' - , 'src' => $url - , 'alt' => 'Thumbnail' - ); - - $this->element('img', $attr); - + $this->element('img', array('src' => $file_thumbnail->url, 'alt' => 'Thumbnail')); } /** diff --git a/js/util.js b/js/util.js index cba6f822eb..b1b6ec82bd 100644 --- a/js/util.js +++ b/js/util.js @@ -18,18 +18,26 @@ $(document).ready(function(){ $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); - $('a.thumbnail').hover( + $("a.thumbnail").hover( function() { - anchor = $(this); - $.get($('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { - anchor.append(data); - $('#thumbnail').fadeIn('def'); - }); + var anchor = $(this); + $("a.thumbnail").children('img').remove(); + + setTimeout(function() { + anchor.closest(".entry-title").addClass('ov'); + $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + }); + }, 250); + + setTimeout(function() { + anchor.children('img').remove(); + anchor.closest(".entry-title").removeClass('ov'); + }, 3000); }, function() { - setTimeout(function() { - $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); - }, 500); + $(this).children('img').remove(); + $(this).closest(".entry-title").removeClass('ov'); } ); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index aa76910f0b..9bc1417b17 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -798,6 +798,9 @@ float:left; width:100%; overflow:hidden; } +.notice .entry-title.ov { +overflow:visible; +} #shownotice .notice .entry-title { font-size:2.2em; } @@ -857,7 +860,7 @@ position:relative; } .notice .attachment img { position:absolute; -top:11px; +top:18px; left:0; z-index:99; } From aa935986b6db6f3290467e4c60d6eab7de26ccb7 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 26 May 2009 01:43:24 +0000 Subject: [PATCH 30/35] Removed unnecessary call to base/css/display.css for 0.8.x --- theme/base/css/facebookapp.css | 1 - 1 file changed, 1 deletion(-) diff --git a/theme/base/css/facebookapp.css b/theme/base/css/facebookapp.css index 163b41fb4c..9f269b96f3 100644 --- a/theme/base/css/facebookapp.css +++ b/theme/base/css/facebookapp.css @@ -1,4 +1,3 @@ -@import url("display.css"); @import url("../../identica/css/display.css"); * { From 0e8358bd2335bfc71ac5b2ee93e866fa5c571c89 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 26 May 2009 02:34:36 +0000 Subject: [PATCH 31/35] Updated stylesheet paths for facebook app --- lib/facebookaction.php | 4 ---- theme/base/css/facebookapp.css | 2 -- 2 files changed, 6 deletions(-) diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 043a078cd5..00db79400d 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -98,10 +98,6 @@ class FacebookAction extends Action // Add a timestamp to the file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts)); - $theme = common_config('site', 'theme'); $ts = filemtime(INSTALLDIR. '/theme/' . $theme .'/css/display.css'); diff --git a/theme/base/css/facebookapp.css b/theme/base/css/facebookapp.css index 9f269b96f3..e6b1c9ee53 100644 --- a/theme/base/css/facebookapp.css +++ b/theme/base/css/facebookapp.css @@ -1,5 +1,3 @@ -@import url("../../identica/css/display.css"); - * { font-size:14px; font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; From c93031c2aa49b8a044e896ca1e07f5f4f429308e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 26 May 2009 03:34:00 +0000 Subject: [PATCH 32/35] Reusing base stylesheet (instead of hoping for FB to import it) in FB app. --- lib/facebookaction.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 00db79400d..637a6284d9 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -97,6 +97,10 @@ class FacebookAction extends Action { // Add a timestamp to the file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); + + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts)); $theme = common_config('site', 'theme'); From 8591031c01c4d35ec8336bb52fb5259d1fdd640a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 26 May 2009 15:05:43 -0400 Subject: [PATCH 33/35] stats reporting from cron --- scripts/statsreport.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 scripts/statsreport.php diff --git a/scripts/statsreport.php b/scripts/statsreport.php new file mode 100644 index 0000000000..e332d856c0 --- /dev/null +++ b/scripts/statsreport.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +. + */ + +# Abort if called from a web server +if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { + print "This script must be run from the command line\n"; + exit(1); +} + +ini_set("max_execution_time", "0"); +ini_set("max_input_time", "0"); +set_time_limit(0); +mb_internal_encoding('UTF-8'); + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('LACONICA', true); + +require_once(INSTALLDIR . '/lib/common.php'); + +Snapshot::check(); From da035331d81bc73f488968d835e4d05a2da975f3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 26 May 2009 17:26:31 -0400 Subject: [PATCH 34/35] fixes during checking of snapshot --- lib/snapshot.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/snapshot.php b/lib/snapshot.php index a014d3435f..4b05b502db 100644 --- a/lib/snapshot.php +++ b/lib/snapshot.php @@ -84,9 +84,8 @@ class Snapshot // hits if (rand() % common_config('snapshot', 'frequency') == 0) { $snapshot = new Snapshot(); - if ($snapshot->take()) { - $snapshot->report(); - } + $snapshot->take(); + $snapshot->report(); } break; case 'cron': @@ -94,11 +93,14 @@ class Snapshot if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { break; } + common_log(LOG_INFO, 'Running snapshot from cron job'); // We're running from the command line; assume + $snapshot = new Snapshot(); - if ($snapshot->take()) { - $snapshot->report(); - } + $snapshot->take(); + common_log(LOG_INFO, count($snapshot->stats) . " statistics being uploaded."); + $snapshot->report(); + break; case 'never': break; @@ -155,6 +157,7 @@ class Snapshot $this->stats['memcached'] = common_config('memcached', 'enabled'); $this->stats['language'] = common_config('site', 'language'); $this->stats['timezone'] = common_config('site', 'timezone'); + } /** @@ -186,7 +189,9 @@ class Snapshot $reporturl = common_config('snapshot', 'reporturl'); - $result = file_get_contents($reporturl, false, $context); + $result = @file_get_contents($reporturl, false, $context); + + return $result; } /** @@ -203,14 +208,14 @@ class Snapshot function tableStats($table) { - $inst = DB_DataObject::Factory($table); + $inst = DB_DataObject::factory($table); - $res = $inst->query('SELECT count(*) as cnt, '. - 'min(created) as first, '. - 'max(created) as last '. - 'from ' . $table); + $inst->selectAdd(); + $inst->selectAdd('count(*) as cnt, '. + 'min(created) as first, '. + 'max(created) as last'); - if ($res) { + if ($inst->find(true)) { $this->stats[$table.'count'] = $inst->cnt; $this->stats[$table.'first'] = $inst->first; $this->stats[$table.'last'] = $inst->last; From 40d4668c7c5cdd41d36b878ad87f7737117efc9c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 26 May 2009 17:28:03 -0400 Subject: [PATCH 35/35] move statsreport.php to reportsnapshot.php --- scripts/reportsnapshot.php | 4 +--- scripts/statsreport.php | 37 ------------------------------------- 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 scripts/statsreport.php diff --git a/scripts/reportsnapshot.php b/scripts/reportsnapshot.php index 7b7724b9bb..e332d856c0 100644 --- a/scripts/reportsnapshot.php +++ b/scripts/reportsnapshot.php @@ -34,6 +34,4 @@ define('LACONICA', true); require_once(INSTALLDIR . '/lib/common.php'); -// All that setup, just for this! - -Snapshot::check(); \ No newline at end of file +Snapshot::check(); diff --git a/scripts/statsreport.php b/scripts/statsreport.php deleted file mode 100644 index e332d856c0..0000000000 --- a/scripts/statsreport.php +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env php -. - */ - -# Abort if called from a web server -if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { - print "This script must be run from the command line\n"; - exit(1); -} - -ini_set("max_execution_time", "0"); -ini_set("max_input_time", "0"); -set_time_limit(0); -mb_internal_encoding('UTF-8'); - -define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('LACONICA', true); - -require_once(INSTALLDIR . '/lib/common.php'); - -Snapshot::check();