first steps towards new skin

darcs-hash:20080610185238-84dde-c073065f5f802be39b97a23105613fac1eeb0bea.gz
This commit is contained in:
Evan Prodromou 2008-06-10 14:52:38 -04:00
parent 4602fd8c07
commit dd0b341b64
4 changed files with 84 additions and 35 deletions

View File

@ -43,7 +43,7 @@ class NewnoticeAction extends Action {
$notice->profile_id = $user->id; # user id *is* profile id $notice->profile_id = $user->id; # user id *is* profile id
$notice->created = DB_DataObject_Cast::dateTime(); $notice->created = DB_DataObject_Cast::dateTime();
# Default theme uses 'content' for something else # Default theme uses 'content' for something else
$notice->content = $this->trimmed('noticecontent'); $notice->content = $this->trimmed('status_textarea');
if (!$notice->content) { if (!$notice->content) {
$this->show_form(_t('No content!')); $this->show_form(_t('No content!'));

View File

@ -36,6 +36,7 @@ $config =
array('site' => array('site' =>
array('name' => 'Just another Laconica microblog', array('name' => 'Just another Laconica microblog',
'server' => 'localhost', 'server' => 'localhost',
'theme' => 'default',
'path' => '/', 'path' => '/',
'fancy' => false), 'fancy' => false),
'syslog' => 'syslog' =>
@ -69,6 +70,7 @@ $config['db'] =
require_once(INSTALLDIR.'/config.php'); require_once(INSTALLDIR.'/config.php');
require_once(INSTALLDIR.'/lib/util.php'); require_once(INSTALLDIR.'/lib/util.php');
require_once(INSTALLDIR.'/lib/action.php'); require_once(INSTALLDIR.'/lib/action.php');
require_once(INSTALLDIR.'/lib/theme.php');
require_once(INSTALLDIR.'/classes/Avatar.php'); require_once(INSTALLDIR.'/classes/Avatar.php');
require_once(INSTALLDIR.'/classes/Notice.php'); require_once(INSTALLDIR.'/classes/Notice.php');

30
lib/theme.php Normal file
View File

@ -0,0 +1,30 @@
<?php
/*
* Laconica - a distributed open-source microblogging tool
* Copyright (C) 2008, Controlez-Vous, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('LACONICA')) { exit(1); }
function theme_file($relative) {
global $config;
return INSTALLDIR.'/theme/'.$config['site']['theme'].'/'.$relative;
}
function theme_path($relative) {
global $config;
return common_path('theme/'.$config['site']['theme'].'/'.$relative);
}

View File

@ -123,7 +123,7 @@ function common_end_xml() {
$xw->flush(); $xw->flush();
} }
function common_show_header($pagetitle, $callable=NULL, $data=NULL) { function common_show_header($pagetitle, $callable=NULL, $data=NULL, $notice=NULL) {
global $config, $xw; global $config, $xw;
header('Content-Type: application/xhtml+xml'); header('Content-Type: application/xhtml+xml');
@ -143,16 +143,15 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL) {
$pagetitle . " - " . $config['site']['name']); $pagetitle . " - " . $config['site']['name']);
common_element('link', array('rel' => 'stylesheet', common_element('link', array('rel' => 'stylesheet',
'type' => 'text/css', 'type' => 'text/css',
'href' => common_path('theme/default/style/html.css'), 'href' => theme_path('display.css'),
'media' => 'screen, projection, tv')); 'media' => 'screen, projection, tv'));
common_element('link', array('rel' => 'stylesheet', foreach (array(6,7) as $ver) {
'type' => 'text/css', if (file_exists(theme_file('ie'.$ver.'.css'))) {
'href' => common_path('theme/default/style/layout.css'), # Yes, IE people should be put in jail.
'media' => 'screen, projection, tv')); $xw->writeComment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
common_element('link', array('rel' => 'stylesheet', 'href="'.theme_path('ie'.$ver.'.css').' /><![endif]');
'type' => 'text/css', }
'href' => common_path('theme/default/style/print.css'), }
'media' => 'print'));
if ($callable) { if ($callable) {
if ($data) { if ($data) {
call_user_func($callable, $data); call_user_func($callable, $data);
@ -162,25 +161,32 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL) {
} }
common_element_end('head'); common_element_end('head');
common_element_start('body'); common_element_start('body');
common_element_start('div', array('id' => 'wrapper')); common_element_start('div', array('id' => 'wrap'));
common_element_start('div', array('id' => 'content'));
common_element_start('div', array('id' => 'header')); common_element_start('div', array('id' => 'header'));
common_element('h1', 'title', $pagetitle); common_nav_menu();
common_element('h2', 'subtitle', $config['site']['name']); common_element_start('a', array('href' => common_local_url('public')));
common_element('img', array('src' => ($config['site']['logo']) ?
($config['site']['logo']) : theme_path('logo.png'),
'alt' => $config['site']['name'],
'id' => 'logo'));
if ($notice && common_logged_in()) {
common_notice_form();
}
common_element_end('div'); common_element_end('div');
common_head_menu(); common_element_start('div', array('id' => 'content'));
common_element_start('div', array('id' => 'page')); if ($notice && common_logged_in()) {
common_views_menu();
}
} }
function common_show_footer() { function common_show_footer() {
global $xw, $config; global $xw, $config;
common_element_start('div', 'footer'); common_element_end('div'); # content div
common_foot_menu(); common_foot_menu();
common_element_start('div', 'footer');
common_license_block(); common_license_block();
common_element_end('div'); common_element_end('div');
common_element_end('div'); common_element_end('div');
common_element_end('div');
common_element_end('div');
common_element_end('body'); common_element_end('body');
common_element_end('html'); common_element_end('html');
common_end_xml(); common_end_xml();
@ -219,30 +225,31 @@ function common_license_block() {
common_element_end('p'); common_element_end('p');
} }
function common_head_menu() { function common_nav_menu() {
$user = common_current_user(); $user = common_current_user();
common_element_start('ul', array('id' => 'menu', 'class' => ($user) ? 'five' : 'three')); common_element_start('ul', array('id' => 'nav'));
common_menu_item(common_local_url('public'), _t('Public')); common_menu_item(common_local_url('public'), _t('Public'));
if ($user) { if ($user) {
common_menu_item(common_local_url('all', array('nickname' =>
$user->nickname)),
_t('Home'));
common_menu_item(common_local_url('showstream', array('nickname' =>
$user->nickname)),
_t('Profile'), $user->fullname || $user->nickname);
common_menu_item(common_local_url('profilesettings'), common_menu_item(common_local_url('profilesettings'),
_t('Settings')); _t('Settings'));
common_menu_item(common_local_url('logout'), common_menu_item(common_local_url('logout'),
_t('Logout')); _t('Logout'));
} else { } else {
common_menu_item(common_local_url('login'), common_menu_item(common_local_url('login'), _t('Login'));
_t('Login')); common_menu_item(common_local_url('register'), _t('Register'));
common_menu_item(common_local_url('register'),
_t('Register'));
} }
common_element_end('ul'); common_element_end('ul');
} }
function common_views_menu() {
common_menu_item(common_local_url('all', array('nickname' =>
$user->nickname)),
_t('Home'));
common_menu_item(common_local_url('showstream', array('nickname' =>
$user->nickname)),
_t('Profile'), $user->fullname || $user->nickname);
}
function common_foot_menu() { function common_foot_menu() {
common_element_start('ul', 'footmenu menuish'); common_element_start('ul', 'footmenu menuish');
common_menu_item(common_local_url('doc', array('title' => 'about')), common_menu_item(common_local_url('doc', array('title' => 'about')),
@ -577,11 +584,21 @@ function common_profile_url($nickname) {
return common_local_url('showstream', array('nickname' => $nickname)); return common_local_url('showstream', array('nickname' => $nickname));
} }
# Don't call if nobody's logged in
function common_notice_form() { function common_notice_form() {
common_element_start('form', array('id' => 'newnotice', 'method' => 'POST', $user = common_current_user();
assert(!is_null($user));
common_element_start('form', array('id' => 'status_form',
'method' => 'POST',
'action' => common_local_url('newnotice'))); 'action' => common_local_url('newnotice')));
common_textarea('noticecontent', _t('What\'s up?')); common_element('label', array('for' => 'status_update',
common_submit('submit', _t('Send')); 'id' => 'status_label'),
_t('What\'s up, ').$user->nickname.'?');
common_element('textarea', 'status_textarea');
common_element('input', array('id' => 'status_submit',
'type' => 'submit',
'value' => _t('Send')));
common_element_end('form'); common_element_end('form');
} }