Browse Source

Merge branch 'master' of https://github.com/savetheinternet/Tinyboard

Conflicts:
	post.php
pull/40/head
czaks 11 years ago
parent
commit
fa66b96240
  1. 2
      .gitignore
  2. 2
      inc/filters.php
  3. 8
      inc/functions.php
  4. 7
      post.php
  5. 2
      templates/themes/basic/theme.php
  6. 38
      templates/themes/catalog/catalog.css
  7. 36
      templates/themes/catalog/catalog.html
  8. 42
      templates/themes/catalog/info.php
  9. 60
      templates/themes/catalog/theme.php
  10. 2
      templates/themes/categories/theme.php
  11. 2
      templates/themes/frameset/theme.php
  12. 5
      templates/themes/recent/theme.php
  13. 2
      templates/themes/rrdtool/theme.php
  14. 6
      templates/themes/sitemap/theme.php

2
.gitignore

@ -14,7 +14,7 @@
/templates/cache
# other stuff
.DS_Store?
.DS_Store
thumbs.db
Icon?
Thumbs.db

2
inc/filters.php

@ -81,7 +81,7 @@ class Filter {
else
$all_boards = false;
$query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :set, :expires, :reason, :board)");
$query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :set, :expires, :reason, :board, 0)");
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
$query->bindValue(':mod', -1);
$query->bindValue(':set', time());

8
inc/functions.php

@ -240,12 +240,12 @@ function create_antibot($board, $thread = null) {
return _create_antibot($board, $thread);
}
function rebuildThemes($action) {
function rebuildThemes($action, $board = false) {
// List themes
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
while ($theme = $query->fetch()) {
rebuildTheme($theme['theme'], $action);
rebuildTheme($theme['theme'], $action, $board);
}
}
@ -262,7 +262,7 @@ function loadThemeConfig($_theme) {
return $theme;
}
function rebuildTheme($theme, $action) {
function rebuildTheme($theme, $action, $board = false) {
global $config, $_theme;
$_theme = $theme;
@ -271,7 +271,7 @@ function rebuildTheme($theme, $action) {
if (file_exists($config['dir']['themes'] . '/' . $_theme . '/theme.php')) {
require_once $config['dir']['themes'] . '/' . $_theme . '/theme.php';
$theme['build_function']($action, themeSettings($_theme));
$theme['build_function']($action, themeSettings($_theme), $board);
}
}

7
post.php

@ -685,8 +685,13 @@ if (isset($_POST['delete'])) {
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
sprintf($config['file_page'], $post['op'] ? $id : $post['thread']) . (!$post['op'] ? '#' . $id : ''));
rebuildThemes('post');
if (!$post['mod']) header('X-Associated-Content: "' . $redirect . '"');
if ($post['op'])
rebuildThemes('post-thread', $board['uri']);
else
rebuildThemes('post', $board['uri']);
header('Location: ' . $redirect, true, $config['redirect_http']);
} else {
if (!file_exists($config['has_installed'])) {

2
templates/themes/basic/theme.php

@ -1,7 +1,7 @@
<?php
require 'info.php';
function basic_build($action, $settings) {
function basic_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)

38
templates/themes/catalog/catalog.css

@ -0,0 +1,38 @@
img {
float:none!important;
margin: auto;
margin-bottom: 12px;
max-height: 150px;
max-width: 200px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.55);
border: 2px solid rgba(153, 153, 153, 0);
}
/*
img:hover {
border: 2px solid rgba(153, 153, 153, 0.27);
}
*/
div.thread {
display: inline-block;
vertical-align: top;
margin-bottom:25px;
margin-left: 20px;
margin-right: 15px;
text-align:center;
font-weight:normal;
width:205px;
overflow:hidden;
position: relative;
font-size:11px;
padding: 15px;
background: rgba(182, 182, 182, 0.12);
border: 2px solid rgba(111, 111, 111, 0.34);
max-height:300px;
}
div.thread:hover {
background: #D6DAF0;
border-color: #B7C5D9;
}

36
templates/themes/catalog/catalog.html

@ -0,0 +1,36 @@
{% filter remove_whitespace %}
<!doctype html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>{{ settings.title }}</title>
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}"/>
<link rel="stylesheet" media="screen" href="{{ config.root }}{{ settings.css }}"/>
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %}
</head>
<body>
{{ boardlist.top }}
<header>
<h1>{{ settings.title }} (<a href="{{link}}">/{{ board }}/</a>)</h1>
<div class="subtitle">{{ settings.subtitle }}</div>
</header>
<ul>
{% for post in recent_posts %}
<div class="thread">
<a href="{{post.link}}">
<img src="{{post.file}}" class="{{post.board}}" title="{{post.bump|date('%b %d %H:%M')}}">
</a>
<span class="replies">
<strong>{{ post.reply_count }} {% if post.reply_count == 1 %}{% trans 'reply' %}{% else %}{% trans 'replies' %}{% endif %}</strong><br/>
{{ post.body }}
</span>
</div>
{% endfor %}
</ul>
<hr/>
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2013 Tinyboard Development Group</p>
</body>
</html>
{% endfilter %}

42
templates/themes/catalog/info.php

@ -0,0 +1,42 @@
<?php
$theme = array();
// Theme name
$theme['name'] = 'Catalog';
// Description (you can use Tinyboard markup here)
$theme['description'] = 'Show a post catalog.';
$theme['version'] = 'v0.1';
// Theme configuration
$theme['config'] = Array();
$theme['config'][] = Array(
'title' => 'Title',
'name' => 'title',
'type' => 'text',
'default' => 'Catalog'
);
$__boards = listBoards();
$__default_boards = Array();
foreach ($__boards as $__board)
$__default_boards[] = $__board['uri'];
$theme['config'][] = Array(
'title' => 'Included boards',
'name' => 'boards',
'type' => 'text',
'comment' => '(space seperated)',
'default' => implode(' ', $__default_boards)
);
$theme['config'][] = Array(
'title' => 'CSS file',
'name' => 'css',
'type' => 'text',
'default' => 'catalog.css',
'comment' => '(eg. "catalog.css")'
);
// Unique function name for building everything
$theme['build_function'] = 'catalog_build';

60
templates/themes/catalog/theme.php

@ -0,0 +1,60 @@
<?php
require 'info.php';
function catalog_build($action, $settings, $board) {
global $config;
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)
// - boards (board list changed)
// - post (a reply has been made)
// - post-thread (a thread has been made)
$boards = explode(' ', $settings['boards']);
if ($action == 'all') {
copy('templates/themes/catalog/catalog.css', $config['dir']['home'] . $settings['css']);
foreach ($boards as $board) {
$b = new Catalog();
$b->build($settings, $board);
}
} elseif ($action == 'post-thread' && in_array($board, $boards)) {
$b = new Catalog();
$b->build($settings, $board);
}
}
// Wrap functions in a class so they don't interfere with normal Tinyboard operations
class Catalog {
public function build($settings, $board_name) {
global $config, $board;
openBoard($board_name);
$recent_images = array();
$recent_posts = array();
$stats = array();
$query = query(sprintf("SELECT *, `id` AS `thread_id`, (SELECT COUNT(*) FROM `posts_%s` WHERE `thread` = `thread_id`) AS `reply_count`, '%s' AS `board` FROM `posts_%s` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name)) or error(db_error());
while ($post = $query->fetch()) {
$post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id']));
$post['board_name'] = $board['name'];
$post['file'] = $config['uri_thumb'] . $post['thumb'];
$recent_posts[] = $post;
}
file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', Array(
'settings' => $settings,
'config' => $config,
'boardlist' => createBoardlist(),
'recent_images' => $recent_images,
'recent_posts' => $recent_posts,
'stats' => $stats,
'board' => $board_name,
'link' => $config['root'] . $board['dir']
)));
}
};

2
templates/themes/categories/theme.php

@ -1,7 +1,7 @@
<?php
require 'info.php';
function categories_build($action, $settings) {
function categories_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)

2
templates/themes/frameset/theme.php

@ -1,7 +1,7 @@
<?php
require 'info.php';
function frameset_build($action, $settings) {
function frameset_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)

5
templates/themes/recent/theme.php

@ -1,12 +1,13 @@
<?php
require 'info.php';
function recentposts_build($action, $settings) {
function recentposts_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)
// - boards (board list changed)
// - post (a post has been made)
// - post-thread (a thread has been made)
$b = new RecentPosts();
$b->build($action, $settings);
@ -23,7 +24,7 @@
$this->excluded = explode(' ', $settings['exclude']);
if ($action == 'all' || $action == 'post')
if ($action == 'all' || $action == 'post' || $action == 'post-thread')
file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings));
}

2
templates/themes/rrdtool/theme.php

@ -1,7 +1,7 @@
<?php
require 'info.php';
function rrdtool_build($action, $settings) {
function rrdtool_build($action, $settings, $board) {
// Possible values for $action:
// - all (rebuild everything, initialization)
// - news (news has been updated)

6
templates/themes/sitemap/theme.php

@ -1,7 +1,7 @@
<?php
require 'info.php';
function sitemap_build($action, $settings) {
function sitemap_build($action, $settings, $board) {
global $config;
// Possible values for $action:
@ -9,6 +9,10 @@
// - news (news has been updated)
// - boards (board list changed)
// - post (a post has been made)
// - thread (a thread has been made)
if ($action != 'post' && $action != 'post-thread')
return;
$boards = explode(' ', $settings['boards']);

Loading…
Cancel
Save