Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x

This commit is contained in:
Evan Prodromou 2009-07-23 14:45:44 -07:00
commit 0dab5f5872
15 changed files with 333 additions and 104 deletions

View File

@ -194,6 +194,9 @@ class RecoverpasswordAction extends Action
'or your registered email address.'));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->element('input', array('name' => 'recover',
'type' => 'hidden',
'value' => _('Recover')));
$this->submit('recover', _('Recover'));
$this->elementEnd('fieldset');
$this->elementEnd('form');

View File

@ -122,6 +122,7 @@ class File extends Memcached_DataObject
}
function isRespectsQuota($user,$fileSize) {
if ($fileSize > common_config('attachments', 'file_quota')) {
return sprintf(_('No file may be larger than %d bytes ' .
'and the file you sent was %d bytes. Try to upload a smaller version.'),
@ -135,8 +136,7 @@ class File extends Memcached_DataObject
if ($total > common_config('attachments', 'user_quota')) {
return sprintf(_('A file this large would exceed your user quota of %d bytes.'), common_config('attachments', 'user_quota'));
}
$query .= ' month(modified) = month(now()) and year(modified) = year(now())';
$query .= ' AND EXTRACT(month FROM file.modified) = EXTRACT(month FROM now()) and EXTRACT(year FROM file.modified) = EXTRACT(year FROM now())';
$this->query($query);
$this->fetch();
$total = $this->total + $fileSize;

View File

@ -98,13 +98,21 @@ class Notice extends Memcached_DataObject
function saveTags()
{
/* extract all #hastags */
$count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
$count = preg_match_all('/(?:^|\s)#([\pL\pN_\-\.]{1,64})/', strtolower($this->content), $match);
if (!$count) {
return true;
}
//turn each into their canonical tag
//this is needed to remove dupes before saving e.g. #hash.tag = #hashtag
$hashtags = array();
for($i=0; $i<count($match[1]); $i++) {
$hashtags[] = common_canonical_tag($match[1][$i]);
}
/* Add them to the database */
foreach(array_unique($match[1]) as $hashtag) {
foreach(array_unique($hashtags) as $hashtag) {
/* elide characters we don't want in the tag */
$this->saveTag($hashtag);
}
@ -113,8 +121,6 @@ class Notice extends Memcached_DataObject
function saveTag($hashtag)
{
$hashtag = common_canonical_tag($hashtag);
$tag = new Notice_tag();
$tag->notice_id = $this->id;
$tag->tag = $hashtag;

View File

@ -199,7 +199,7 @@ class Profile extends Memcached_DataObject
$query .= ' order by id DESC';
if (!is_null($offset)) {
$query .= " limit $offset, $limit";
$query .= " LIMIT $limit OFFSET $offset";
}
$notice->query($query);

View File

@ -1,4 +1,3 @@
/* local and remote users have profiles */
create sequence profile_seq;
@ -41,6 +40,19 @@ create table sms_carrier (
modified timestamp /* comment 'date this record was modified ' */
);
create sequence design_seq;
create table design (
id bigint default nextval('design_seq') /* comment 'design ID'*/,
backgroundcolor integer /* comment 'main background color'*/ ,
contentcolor integer /*comment 'content area background color'*/ ,
sidebarcolor integer /*comment 'sidebar background color'*/ ,
textcolor integer /*comment 'text color'*/ ,
linkcolor integer /*comment 'link color'*/,
backgroundimage varchar(255) /*comment 'background image, if any'*/,
disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/,
primary key (id)
);
/* local users */
create table "user" (
@ -72,6 +84,8 @@ create table "user" (
autosubscribe integer default 0 /* comment 'automatically subscribe to users who subscribe to us' */,
urlshorteningservice varchar(50) default 'ur1.ca' /* comment 'service to use for auto-shortening URLs' */,
inboxed integer default 0 /* comment 'has an inbox been created for this user?' */,
design_id integer /* comment 'id of a design' */references design(id),
viewdesigns integer default 1 /* comment 'whether to view user-provided designs'*/,
created timestamp not null default CURRENT_TIMESTAMP /* comment 'date this record was created' */,
modified timestamp /* comment 'date this record was modified' */
@ -376,20 +390,6 @@ create table profile_block (
);
create sequence design_seq;
create table design (
id bigint default nextval('design_seq') /* comment 'design ID'*/,
backgroundcolor integer /* comment 'main background color'*/ ,
contentcolor integer /*comment 'content area background color'*/ ,
sidebarcolor integer /*comment 'sidebar background color'*/ ,
textcolor integer /*comment 'text color'*/ ,
linkcolor integer /*comment 'link color'*/,
backgroundimage varchar(255) /*comment 'background image, if any'*/,
disposition int default 1 /*comment 'bit 1 = hide background image, bit 2 = display background image, bit 4 = tile background image'*/,
primary key (id)
);
create sequence user_group_seq;
create table user_group (
@ -441,7 +441,6 @@ create table group_inbox (
group_id integer not null /* comment 'group receiving the message' references user_group (id) */,
notice_id integer not null /* comment 'notice received' references notice (id) */,
created timestamp not null default CURRENT_TIMESTAMP /* comment 'date the notice was created' */,
primary key (group_id, notice_id)
);
create index group_inbox_created_idx on group_inbox using btree(created);
@ -456,13 +455,14 @@ create table file (
size integer,
title varchar(255),
date integer,
protected integer
protected integer,
filename text /* comment 'if a local file, name of the file' */,
modified timestamp default CURRENT_TIMESTAMP /* comment 'date this record was modified'*/
);
create sequence file_oembed_seq;
create table file_oembed (
id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
file_id bigint unique,
file_id bigint default nextval('file_oembed_seq') primary key /* comment 'unique identifier' */,
version varchar(20),
type varchar(20),
provider varchar(50),
@ -478,8 +478,7 @@ create table file_oembed (
create sequence file_redirection_seq;
create table file_redirection (
id bigint default nextval('file_redirection_seq') primary key /* comment 'unique identifier' */,
url varchar(255) unique,
url varchar(255) primary key,
file_id bigint,
redirections integer,
httpcode integer
@ -487,8 +486,7 @@ create table file_redirection (
create sequence file_thumbnail_seq;
create table file_thumbnail (
id bigint default nextval('file_thumbnail_seq') primary key /* comment 'unique identifier' */,
file_id bigint unique,
file_id bigint primary key,
url varchar(255) unique,
width integer,
height integer
@ -496,11 +494,10 @@ create table file_thumbnail (
create sequence file_to_post_seq;
create table file_to_post (
id bigint default nextval('file_to_post_seq') primary key /* comment 'unique identifier' */,
file_id bigint,
post_id bigint,
unique(file_id, post_id)
primary key (file_id, post_id)
);
create table group_block (

View File

@ -1,12 +1,14 @@
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteEngine On
# NOTE: change this to your actual Laconica path; may be "/".
# NOTE: change this to your actual Laconica path; may be "/".
RewriteBase /mublog/
RewriteBase /mublog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?p=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?p=$1 [L,QSA]
</IfModule>
<FilesMatch "\.(ini)">
Order allow,deny

View File

@ -165,7 +165,8 @@ function main()
if (!$user && common_config('site', 'private') &&
!in_array($action, array('login', 'openidlogin', 'finishopenidlogin',
'recoverpassword', 'api', 'doc', 'register'))) {
'recoverpassword', 'api', 'doc', 'register')) &&
!preg_match('/rss$/', $action)) {
common_redirect(common_local_url('login'));
return;
}

View File

@ -88,7 +88,9 @@ class DBQueueManager extends QueueManager
do {
$qi = Queue_item::top($queue);
if (!empty($qi)) {
if (empty($qi)) {
sleep(1);
} else {
$notice = Notice::staticGet('id', $qi->notice_id);
if (!empty($notice)) {
$result = $notice;

View File

@ -211,7 +211,7 @@ class Router
array('tag' => '[a-zA-Z0-9]+'));
$m->connect('tag/:tag',
array('action' => 'tag'),
array('tag' => '[a-zA-Z0-9]+'));
array('tag' => '[\pL\pN_\-\.]{1,64}'));
$m->connect('peopletag/:tag',
array('action' => 'peopletag'),

View File

@ -97,15 +97,48 @@ class Rss10Action extends Action
{
// Parent handling, including cache check
parent::handle($args);
// Get the list of notices
if (empty($this->tag)) {
$this->notices = $this->getNotices($this->limit);
} else {
$this->notices = $this->getTaggedNotices($this->tag, $this->limit);
if (common_config('site', 'private')) {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
# This header makes basic auth go
header('WWW-Authenticate: Basic realm="Laconica RSS"');
# If the user hits cancel -- bam!
$this->show_basic_auth_error();
return;
} else {
$nickname = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if (!common_check_user($nickname, $password)) {
# basic authentication failed
list($proxy, $ip) = common_client_ip();
common_log(LOG_WARNING, "Failed RSS auth attempt, nickname = $nickname, proxy = $proxy, ip = $ip.");
$this->show_basic_auth_error();
return;
}
}
}
// Get the list of notices
$this->notices = $this->getNotices($this->limit);
$this->showRss();
}
function show_basic_auth_error()
{
header('HTTP/1.1 401 Unauthorized');
header('Content-Type: application/xml; charset=utf-8');
$this->startXML();
$this->elementStart('hash');
$this->element('error', null, 'Could not authenticate you.');
$this->element('request', null, $_SERVER['REQUEST_URI']);
$this->elementEnd('hash');
$this->endXML();
}
/**
* Get the notices to output in this stream
*
@ -193,24 +226,6 @@ class Rss10Action extends Action
}
}
// XXX: Surely there should be a common function to do this?
function extract_tags ($string)
{
$count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($string), $match);
if (!count)
{
return array();
}
$rv = array();
foreach ($match[1] as $tag)
{
$rv[] = common_canonical_tag($tag);
}
return array_unique($rv);
}
function showItem($notice)
{
$profile = Profile::staticGet($notice->profile_id);
@ -269,26 +284,28 @@ class Rss10Action extends Action
$this->element('sioc:links_to', array('rdf:resource'=>$attachment->url));
}
}
$tags = $this->extract_tags($notice->content);
if (!empty($tags)) {
foreach ($tags as $tag)
{
$tagpage = common_local_url('tag', array('tag' => $tag));
$tag = new Notice_tag();
$tag->notice_id = $notice->id;
if ($tag->find()) {
$entry['tags']=array();
while ($tag->fetch()) {
$tagpage = common_local_url('tag', array('tag' => $tag->tag));
if ( in_array($tag, $this->tags_already_output) ) {
$this->element('ctag:tagged', array('rdf:resource'=>$tagpage.'#concept'));
continue;
}
$tagrss = common_local_url('tagrss', array('tag' => $tag));
$tagrss = common_local_url('tagrss', array('tag' => $tag->tag));
$this->elementStart('ctag:tagged');
$this->elementStart('ctag:Tag', array('rdf:about'=>$tagpage.'#concept', 'ctag:label'=>$tag));
$this->elementStart('ctag:Tag', array('rdf:about'=>$tagpage.'#concept', 'ctag:label'=>$tag->tag));
$this->element('foaf:page', array('rdf:resource'=>$tagpage));
$this->element('rdfs:seeAlso', array('rdf:resource'=>$tagrss));
$this->elementEnd('ctag:Tag');
$this->elementEnd('ctag:tagged');
$this->tags_already_output[] = $tag;
$this->tags_already_output[] = $tag->tag;
}
}
$this->elementEnd('item');

View File

@ -265,6 +265,18 @@ class TwitterapiAction extends Action
}
}
*/
// Tags/Categories
$tag = new Notice_tag();
$tag->notice_id = $notice->id;
if ($tag->find()) {
$entry['tags']=array();
while ($tag->fetch()) {
$entry['tags'][]=$tag->tag;
}
}
$tag->free();
// RSS Item specific
$entry['description'] = $entry['content'];
$entry['pubDate'] = common_date_rfc2822($notice->created);
@ -442,6 +454,12 @@ class TwitterapiAction extends Action
$enclosure = $entry['enclosures'][0];
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
}
if($entry['tags']){
foreach($entry['tags'] as $tag){
$this->element('category', null,$tag);
}
}
$this->elementEnd('item');
}

View File

@ -404,7 +404,7 @@ function common_render_text($text)
$r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
$r = common_replace_urls_callback($r, 'common_linkify');
$r = preg_replace('/(^|\(|\[|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
$r = preg_replace('/(^|\(|\[|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
// XXX: machine tags
return $r;
}

View File

@ -28,7 +28,8 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$helptext = <<<ENDOFHELP
getvaliddaemons.php - print out the currently configured PID directory
getvaliddaemons.php - print out a list of valid daemons that should be started
by the startdaemons script
ENDOFHELP;

View File

@ -12,12 +12,12 @@ img { display:block; border:0; }
a abbr { cursor: pointer; border-bottom:0; }
table { border-collapse:collapse; }
ol { list-style-position:inside; }
html { font-size: 100%; background-color:#fff; }
html { font-size: 87.5%; }
body {
background-color:#fff;
color:#000;
font-family:sans-serif;
font-size:0.75em;
font-size:1em;
line-height:normal;
position:relative;
height:100%;
@ -471,6 +471,24 @@ margin-bottom:7px;
#form_notice #notice_submit label {
display:none;
}
#form_notice label[for=notice_data-attach],
#form_notice #notice_data-attach {
position:absolute;
top:87px;
cursor:pointer;
}
#form_notice label[for=notice_data-attach] {
text-indent:-9999px;
left:82%;
width:16px;
height:16px;
}
#form_notice #notice_data-attach {
left:34.6%;
padding:0;
height:16px;
}
#form_notice .form_note {
position:absolute;
top:-10px;
@ -488,6 +506,7 @@ font-weight:bold;
line-height:1.15;
padding:1px 2px;
}
#form_notice #notice_action-submit {
width:14%;
height:35px;
@ -505,6 +524,26 @@ margin-bottom:7px;
margin-left:18px;
float:left;
}
#form_notice .error,
#form_notice .success {
float:left;
clear:both;
width:81.5%;
margin-bottom:0;
line-height:1.618;
}
#form_notice #notice_data-attach_selected code {
float:left;
width:90%;
display:block;
font-size:1.1em;
line-height:1.8;
overflow:auto;
}
#form_notice #notice_data-attach_selected button {
float:right;
font-size:0.8em;
}
/* entity_profile */
@ -746,17 +785,18 @@ float:left;
width:100%;
border-top-width:1px;
border-top-style:dotted;
font-size:1.2em;
}
.notices li {
list-style-type:none;
line-height:1.1;
width:94%;
padding-right:5%;
padding-left:1%;
min-height:47px;
}
.notices .notices {
margin-top:7px;
margin-left:2%;
width:98%;
float:left;
}
/* NOTICES */
#notices_primary {
@ -805,13 +845,17 @@ text-decoration:underline;
.notice .entry-title {
float:none;
display:inline;
width:100%;
overflow:hidden;
display:inline;
}
#shownotice .notice .entry-title {
font-size:2.2em;
}
#conversation .notice .entry-title {
display:block;
width:90%;
}
.notice p.entry-content {
display:inline;
@ -887,13 +931,12 @@ outline:none;
.notice-options {
padding-left:2%;
float:left;
width:50%;
font-size:0.95em;
width:12.5%;
width:16px;
float:right;
display:none;
}
.notices li.hover div.notice-options {
.notices li:hover div.notice-options {
display:block;
}
@ -917,7 +960,7 @@ top:30px;
right:7px;
}
.notice-options .notice_delete {
bottom:7px;
top:47px;
right:7px;
}
.notice-options .notice_reply dt {
@ -958,6 +1001,97 @@ border:0;
padding:0;
}
.notice .attachment {
position:relative;
padding-left:16px;
}
#attachments .attachment {
padding-left:0;
}
.notice .attachment img {
position:absolute;
top:18px;
left:0;
z-index:99;
}
#shownotice .notice .attachment img {
position:static;
}
#attachments {
clear:both;
float:left;
width:100%;
margin-top:18px;
}
#attachments dt {
font-weight:bold;
font-size:1.3em;
margin-bottom:4px;
}
#attachments ol li {
margin-bottom:18px;
list-style-type:decimal;
float:left;
clear:both;
}
#jOverlayContent,
#jOverlayContent #content,
#jOverlayContent #content_inner {
width: auto !important;
margin-bottom:0;
}
#jOverlayContent #content {
padding:11px;
min-height:auto;
}
#jOverlayContent .external span {
display:block;
margin-bottom:11px;
}
#jOverlayContent button {
position:absolute;
top:0;
right:0;
width:29px;
height:29px;
text-align:center;
font-weight:bold;
padding:0;
}
#jOverlayContent h1 {
max-width:425px;
}
#jOverlayContent #content {
border-radius:7px;
-moz-border-radius:7px;
-webkit-border-radius:7px;
}
#jOverlayLoading {
top:5%;
left:40%;
}
#attachment_view img {
max-width:480px;
max-height:480px;
}
#attachment_view #oembed_info {
margin-top:11px;
}
#attachment_view #oembed_info dt,
#attachment_view #oembed_info dd {
float:left;
}
#attachment_view #oembed_info dt {
clear:left;
margin-right:11px;
font-weight:bold;
}
#attachment_view #oembed_info dt:after {
content: ":";
}
#usergroups #new_group {
float: left;
@ -1218,7 +1352,8 @@ clear:both;
#outbox.user_in #content,
#subscriptions.user_in #content,
#subscribers.user_in #content,
#showgroup.user_in #content {
#showgroup.user_in #content,
#conversation.user_in #content {
padding-top:160px;
}
@ -1243,6 +1378,14 @@ padding-top:160px;
display:none;
}
#jOverlayContent #core #content {
padding-top:11px;
}
#jOverlayContent #core {
background:none;
padding-top:0;
}
html,
body,
@ -1311,24 +1454,23 @@ border-top-color:#87B4C8;
}
#content .notice p.entry-content a:visited {
background-color:#fcfcfc;
}
#content .notice p.entry-content .vcard a {
background-color:#fcfffc;
}
#aside_primary {
background-color:#DDFFCC;
}
#notice_text-count {
color:#333;
color:#000000;
}
#form_notice.warning #notice_text-count {
color:#000;
color:#000000;
}
#form_notice label[for=notice_data-attach] {
background:transparent url(../../base/images/icons/twotone/green/clip-01.gif) no-repeat 0 45%;
}
#form_notice #notice_data-attach {
opacity:0;
}
#form_notice.processing #notice_action-submit {
background:#fff url(../../base/images/icons/icon_processing.gif) no-repeat 47% 47%;
cursor:wait;
@ -1426,8 +1568,11 @@ background-image:url(../images/icons/twotone/green/shield.gif);
/* NOTICES */
.notices li.over {
background-color:#fcfcfc;
.notice .attachment {
background:transparent url(../../base/images/icons/twotone/green/clip-02.gif) no-repeat 0 45%;
}
#attachments .attachment {
background:none;
}
.notice-options .notice_reply a,
@ -1451,10 +1596,24 @@ background:transparent url(../images/icons/icon_trash.gif) no-repeat 0 45%;
.notices div.notice-options {
opacity:0.4;
}
.notices li.hover div.entry-content,
.notices li.hover div.notice-options {
.notices li:hover div.entry-content,
.notices li:hover div.notice-options {
opacity:1;
}
.notices .notices {
background-color:rgba(200, 200, 200, 0.01);
}
.notices .notices .notices {
background-color:rgba(200, 200, 200, 0.02);
}
.notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.03);
}
.notices .notices .notices .notices .notices {
background-color:rgba(200, 200, 200, 0.04);
}
div.entry-content {
color:#333;
}
@ -1462,8 +1621,11 @@ div.notice-options a,
div.notice-options input {
font-family:sans-serif;
}
.notices li.hover {
background-color:#fcfcfc;
#content .notices li:hover {
background-color:rgba(240, 240, 240, 0.2);
}
#conversation .notices li:hover {
background-color:transparent;
}
/*END: NOTICES */

View File

@ -8,6 +8,16 @@ color:#fff;
background-color:#ddffcc;
}
#form_notice .form_note + label {
position:absolute;
top:25px;
left:83%;
text-indent:-9999px;
height:16px;
width:16px;
display:block;
}
#aside_primary {
width:181px;
}
@ -32,3 +42,13 @@ top:158px;
#subscribers #content {
padding-top:138px;
}
.notice {
z-index:1;
}
.notice:hover {
z-index:9999;
}
.notice .thumbnail img {
z-index:9999;
}