more twiddling

Placeholder for broadcasting notice updates.

Fixup the local url function to include server and path.

Add server and path to configuration array.

Make new notice 303 redirect to shownotice.

Make redirects work.

Add link in streams to notices.

darcs-hash:20080517144642-84dde-c267a6e3bb0717ad5a3a819a7cf65fdd5817ea8e.gz
This commit is contained in:
Evan Prodromou 2008-05-17 10:46:42 -04:00
parent 0474128619
commit 2d58199266
4 changed files with 36 additions and 13 deletions

View File

@ -28,15 +28,12 @@ class NewnoticeAction extends Action {
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_t('Not logged in.')); common_user_error(_t('Not logged in.'));
} else if ($this->arg('METHOD') == 'POST') { } else if ($this->arg('METHOD') == 'POST') {
if ($this->save_new_notice()) { $id = $this->save_new_notice();
# XXX: smarter redirects
$user = common_current_user(); if ($id) {
assert(!is_null($user)); # see if... above common_broadcast_notices($id);
# XXX: redirect to source common_redirect(common_local_url('shownotice',
# XXX: use Ajax instead of a redirect array('notice' => $id)), 303);
common_redirect(common_local_url('all',
array('nickname' =>
$user->nickname)));
} else { } else {
common_server_error(_t('Problem saving notice.')); common_server_error(_t('Problem saving notice.'));
} }

View File

@ -21,6 +21,9 @@
+ common_local_url() + common_local_url()
- configuration for DB_DataObject - configuration for DB_DataObject
+ date formatting + date formatting
+ new notice redirects to notice page
+ date in shown notice links to notice page
+ common_redirect()
- release 0.1 - release 0.1
- require valid nicknames - require valid nicknames
- store canonical username for comparison and fetch - store canonical username for comparison and fetch

View File

@ -33,7 +33,9 @@ define('MAX_AVATAR_SIZE', 256 * 1024);
$config = $config =
array('site' => array('site' =>
array('name' => 'Just another µB'), array('name' => 'Just another µB',
'server' => 'localhost',
'path' => '/'),
'avatar' => 'avatar' =>
array('directory' => INSTALLDIR . 'files', array('directory' => INSTALLDIR . 'files',
'path' => '/files'), 'path' => '/files'),
@ -258,13 +260,13 @@ function common_avatar_url($filename) {
} }
function common_local_url($action, $args) { function common_local_url($action, $args) {
global $config;
/* XXX: pretty URLs */ /* XXX: pretty URLs */
$extra = ''; $extra = '';
foreach ($args as $key => $value) { foreach ($args as $key => $value) {
$extra .= "&${key}=${value}"; $extra .= "&${key}=${value}";
} }
/* XXX: correct path */ return "http://".$config['site']['server'].'/'.$config['site']['path']."/index.php?action=${action}${extra}";
return "/index.php?action=${action}${extra}";
} }
function commmon_date_string($dt) { function commmon_date_string($dt) {
@ -272,6 +274,25 @@ function commmon_date_string($dt) {
return date(DATE_RFC822); return date(DATE_RFC822);
} }
function common_redirect($url, $code=307) {
static $status = (301 => "Moved Permanently",
302 => "Found",
303 => "See Other",
307 => "Temporary Redirect");
header("Status: ${code} $status[$code]");
header("Location: $url");
common_element('a', array('href' => $url), $url);
}
function common_broadcast_notices($id) {
// XXX: broadcast notices to remote subscribers
// XXX: broadcast notices to SMS
// XXX: broadcast notices to Jabber
// XXX: broadcast notices to other IM
// XXX: use a queue system like http://code.google.com/p/microapps/wiki/NQDQ
return true;
}
// XXX: set up gettext // XXX: set up gettext
function _t($str) { $str } function _t($str) { $str }

View File

@ -47,7 +47,9 @@ class StreamAction extends Action {
$profile->nickname); $profile->nickname);
# FIXME: URL, image, video, audio # FIXME: URL, image, video, audio
common_element('span', array('class' => 'content'), $notice->content); common_element('span', array('class' => 'content'), $notice->content);
common_element('span', array('class' => 'date'), $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
common_element('a', array('class' => 'notice',
'href' => $noticeurl),
common_date_string($notice->created)); common_date_string($notice->created));
common_end_element('div'); common_end_element('div');
} }