summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-06-10 14:52:38 -0400
committerEvan Prodromou <evan@prodromou.name>2008-06-10 14:52:38 -0400
commitdd0b341b643d68d92c4b23fc8188e16110c3c1ab (patch)
treeb77efc0355cb3089364cab72a93819d2c4279d37 /lib
parent4602fd8c079980ee1f30b280d782cbda28746ea5 (diff)
first steps towards new skin
darcs-hash:20080610185238-84dde-c073065f5f802be39b97a23105613fac1eeb0bea.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/common.php2
-rw-r--r--lib/theme.php30
-rw-r--r--lib/util.php85
3 files changed, 83 insertions, 34 deletions
diff --git a/lib/common.php b/lib/common.php
index f910b3613..198c8feaf 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -36,6 +36,7 @@ $config =
array('site' =>
array('name' => 'Just another Laconica microblog',
'server' => 'localhost',
+ 'theme' => 'default',
'path' => '/',
'fancy' => false),
'syslog' =>
@@ -69,6 +70,7 @@ $config['db'] =
require_once(INSTALLDIR.'/config.php');
require_once(INSTALLDIR.'/lib/util.php');
require_once(INSTALLDIR.'/lib/action.php');
+require_once(INSTALLDIR.'/lib/theme.php');
require_once(INSTALLDIR.'/classes/Avatar.php');
require_once(INSTALLDIR.'/classes/Notice.php');
diff --git a/lib/theme.php b/lib/theme.php
new file mode 100644
index 000000000..d1e82596e
--- /dev/null
+++ b/lib/theme.php
@@ -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);
+} \ No newline at end of file
diff --git a/lib/util.php b/lib/util.php
index 7d27c1090..fe225e898 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -123,7 +123,7 @@ function common_end_xml() {
$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;
header('Content-Type: application/xhtml+xml');
@@ -143,16 +143,15 @@ function common_show_header($pagetitle, $callable=NULL, $data=NULL) {
$pagetitle . " - " . $config['site']['name']);
common_element('link', array('rel' => 'stylesheet',
'type' => 'text/css',
- 'href' => common_path('theme/default/style/html.css'),
+ 'href' => theme_path('display.css'),
'media' => 'screen, projection, tv'));
- common_element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => common_path('theme/default/style/layout.css'),
- 'media' => 'screen, projection, tv'));
- common_element('link', array('rel' => 'stylesheet',
- 'type' => 'text/css',
- 'href' => common_path('theme/default/style/print.css'),
- 'media' => 'print'));
+ foreach (array(6,7) as $ver) {
+ if (file_exists(theme_file('ie'.$ver.'.css'))) {
+ # Yes, IE people should be put in jail.
+ $xw->writeComment('[if lte IE '.$ver.']><link rel="stylesheet" type="text/css" '.
+ 'href="'.theme_path('ie'.$ver.'.css').' /><![endif]');
+ }
+ }
if ($callable) {
if ($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_start('body');
- common_element_start('div', array('id' => 'wrapper'));
- common_element_start('div', array('id' => 'content'));
+ common_element_start('div', array('id' => 'wrap'));
common_element_start('div', array('id' => 'header'));
- common_element('h1', 'title', $pagetitle);
- common_element('h2', 'subtitle', $config['site']['name']);
+ common_nav_menu();
+ 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_head_menu();
- common_element_start('div', array('id' => 'page'));
+ common_element_start('div', array('id' => 'content'));
+ if ($notice && common_logged_in()) {
+ common_views_menu();
+ }
}
function common_show_footer() {
global $xw, $config;
- common_element_start('div', 'footer');
+ common_element_end('div'); # content div
common_foot_menu();
+ common_element_start('div', 'footer');
common_license_block();
common_element_end('div');
common_element_end('div');
- common_element_end('div');
- common_element_end('div');
common_element_end('body');
common_element_end('html');
common_end_xml();
@@ -219,30 +225,31 @@ function common_license_block() {
common_element_end('p');
}
-function common_head_menu() {
+function common_nav_menu() {
$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'));
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'),
_t('Settings'));
common_menu_item(common_local_url('logout'),
_t('Logout'));
} else {
- common_menu_item(common_local_url('login'),
- _t('Login'));
- common_menu_item(common_local_url('register'),
- _t('Register'));
+ common_menu_item(common_local_url('login'), _t('Login'));
+ common_menu_item(common_local_url('register'), _t('Register'));
}
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() {
common_element_start('ul', 'footmenu menuish');
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));
}
+# Don't call if nobody's logged in
+
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')));
- common_textarea('noticecontent', _t('What\'s up?'));
- common_submit('submit', _t('Send'));
+ common_element('label', array('for' => 'status_update',
+ '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');
}