From 3de0e897be3ad38deb9674c02d3e5f8bfc611b07 Mon Sep 17 00:00:00 2001
From: 8n-tech <8n-tech@users.noreply.github.com>
Date: Tue, 21 Apr 2015 11:08:47 +1000
Subject: [PATCH] Multiple boardlist enhancements.
#467 - Reduced and modified columns.
#467 - Styling changes across all supported stylesheets.
#467 - PPH now reflects last hour's posts count and has average in title.
#467 - Removed precision, except for boards that have between 0~1 posts.
#467 - Fixed issue where inline board tags pointed to the HTML file, rendering them nonfunctional for noJS users.
Misc - Fixed quote color in certain stylesheets.
Signed-off-by: 8n-tech <8n-tech@users.noreply.github.com>
---
board-search.php | 9 +++-
boards.php | 8 +--
inc/functions.php | 5 ++
inc/instance-config.php | 1 +
js/board-directory.js | 33 ++++++++++--
stylesheets/dark.css | 11 +++-
stylesheets/photon.css | 10 +++-
stylesheets/redchanit.css | 10 +++-
stylesheets/style.css | 29 ++++++++++-
stylesheets/tomorrow.css | 11 +++-
stylesheets/yotsuba.css | 7 +++
templates/8chan/boards-search.html | 20 +++++---
templates/8chan/boards-table.html | 16 +++---
templates/8chan/boards.html | 80 ------------------------------
14 files changed, 137 insertions(+), 113 deletions(-)
delete mode 100644 templates/8chan/boards.html
diff --git a/board-search.php b/board-search.php
index 9c553793..a422a514 100644
--- a/board-search.php
+++ b/board-search.php
@@ -174,9 +174,14 @@ foreach ($response['boards'] as $boardUri => &$board) {
$board['active'] = (int) $boardActivity['active'][ $boardUri ];
}
if (isset($boardActivity['average'][ $boardUri ])) {
- $precision = 1;
+ $precision = 0;
- $board['pph'] = round( $boardActivity['average'][ $boardUri ], $precision );
+ if ($boardActivity['average'][ $boardUri ] > 0 && $boardActivity['average'][ $boardUri ] < 10) {
+ $precision = 1;
+ }
+
+ $board['pph_average'] = round( $boardActivity['average'][ $boardUri ], $precision );
+ $board['pph'] = round( $boardActivity['average'][ $boardUri ], 0 );
$board['ppd'] = round( $boardActivity['today'][ $boardUri ], $precision );
unset( $precision );
diff --git a/boards.php b/boards.php
index 233b81e2..b307fe87 100644
--- a/boards.php
+++ b/boards.php
@@ -43,7 +43,7 @@ $tagQueryGet = $_GET;
$tagQueryTags = isset($tagQueryGet['tags']) ? $tagQueryGet['tags'] : "";
unset($tagQueryGet['tags']);
$tagQueryGet['tags'] = $tagQueryTags;
-$tag_query = "?" . http_build_query( $tagQueryGet ) . ($tagQueryTags != "" ? "+" : "");
+$tag_query = "/boards.php?" . http_build_query( $tagQueryGet ) . ($tagQueryTags != "" ? "+" : "");
/* Create and distribute page */
// buildJavascript();
@@ -103,14 +103,14 @@ if (php_sapi_name() == 'cli') {
file_write("boards.html", $pageHTML);
file_write("boards.json", json_encode($nonAssociativeBoardList));
-
+
$topbar = array();
foreach ($boards as $i => $b) {
- if (!in_array($b['uri'], $config['no_top_bar_boards'])) {
+ if (is_array($config['no_top_bar_boards']) && !in_array($b['uri'], $config['no_top_bar_boards'])) {
$topbar[] = $b;
}
}
-
+
file_write("boards-top20.json", json_encode(array_splice($topbar, 0, 48)));
}
diff --git a/inc/functions.php b/inc/functions.php
index 7116b168..ebdbcc53 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -873,6 +873,7 @@ function fetchBoardActivity( array $uris = array(), $forTime = false, $detailed
'active' => array(),
'today' => array(),
'average' => array(),
+ 'last' => array(),
);
// Query for stats for these boards.
@@ -893,6 +894,10 @@ function fetchBoardActivity( array $uris = array(), $forTime = false, $detailed
// Format the results.
foreach ($bsResult as $bsRow) {
+ if ($bsRow['stat_hour'] == $forHour) {
+ $boardActivity['last'][$bsRow['stat_uri']] = $bsRow['post_count'];
+ }
+
// Do we need to define the arrays for this URI?
if (!isset($boardActivity['active'][$bsRow['stat_uri']])) {
if ($bsRow['stat_hour'] <= $forHour && $bsRow['stat_hour'] >= $yesterHour) {
diff --git a/inc/instance-config.php b/inc/instance-config.php
index cacaf6ee..a212d323 100644
--- a/inc/instance-config.php
+++ b/inc/instance-config.php
@@ -228,6 +228,7 @@ $config['enable_antibot'] = false;
$config['spam']['unicode'] = false;
$config['twig_cache'] = false;
$config['report_captcha'] = true;
+$config['no_top_bar_boards'] = false;
$config['page_404'] = 'page_404';
diff --git a/js/board-directory.js b/js/board-directory.js
index 94ccf9fd..64b8aded 100644
--- a/js/board-directory.js
+++ b/js/board-directory.js
@@ -49,7 +49,7 @@
// Content wrapper
// Used to help constrain contents to their
.
- 'board-content-wrap' : "",
+ 'board-content-wrap' : "",
// Individual items or parts of a single table cell.
'board-datum-lang' : "",
@@ -57,6 +57,7 @@
'board-datum-sfw' : "",
'board-datum-nsfw' : "",
'board-datum-tags' : "",
+ 'board-datum-pph' : "",
// Tag list.
@@ -164,9 +165,16 @@
var $content = boardlist.build.boardcell[column]( row, value );
if ($content instanceof jQuery) {
- // We use .append() instead of .appendTo() as we do elsewhere
- // because $content can be multiple elements.
- $wrap.append( $content );
+ if ($content.is("." + $wrap[0].class)) {
+ // Our new content has the same classes as the wrapper.
+ // Replace the old wrapper.
+ $wrap = $content;
+ }
+ else {
+ // We use .append() instead of .appendTo() as we do elsewhere
+ // because $content can be multiple elements.
+ $wrap.append( $content );
+ }
}
else if (typeof $content === "string") {
$wrap.html( $content );
@@ -199,7 +207,14 @@
else {
return $link[0].outerHTML;
}
- }
+ },
+ 'pph' : function(row, value) {
+ return $( boardlist.options.template['board-datum-pph'] )
+ .attr( 'title', function(index, value) {
+ return value.replace("%1", row['pph']).replace("%2", row['pph_average']);
+ } )
+ .text( row['pph'] );
+ },
},
lastSearch : function(search) {
@@ -346,6 +361,14 @@
target = boardlist.options.selector.boardlist;
}
+ // Parse ?GET parameters into lastSearch object.
+ if (window.location.search != "" && window.location.search.length > 0) {
+ // ?a=1&b=2 -> a=1&b=2 -> { a : 1, b : 2 }
+ window.location.search.substr(1).split("&").forEach( function(item) {
+ boardlist.lastSearch[item.split("=")[0]] = item.split("=")[1];
+ } );
+ }
+
var $boardlist = $(target);
if ($boardlist.length > 0 ) {
diff --git a/stylesheets/dark.css b/stylesheets/dark.css
index 0cf4c4f4..7a0ce6da 100644
--- a/stylesheets/dark.css
+++ b/stylesheets/dark.css
@@ -8,7 +8,7 @@ body {
font-family: sans-serif;
font-size: 12px;
}
-span.quote {
+.quote {
color:#B8D962;
}
h1 {
@@ -223,9 +223,16 @@ table tbody tr:nth-of-type( even ) {
}
table.board-list-table .board-uri .board-sfw {
- color: #446655;
+ color: #CCCCCC;
}
tbody.board-list-omitted td {
background: #333333;
border-color: #555555;
+}
+
+table.board-list-table .board-tags .board-cell:hover {
+ background: #1e1e1e;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #333333;
}
\ No newline at end of file
diff --git a/stylesheets/photon.css b/stylesheets/photon.css
index 4d876ea0..cb46efa4 100644
--- a/stylesheets/photon.css
+++ b/stylesheets/photon.css
@@ -351,9 +351,17 @@ table tbody tr:nth-of-type( even ) {
}
table.board-list-table .board-uri .board-sfw {
- color: #333333;
+ color: #8A8A8A;
}
tbody.board-list-omitted td {
background: transparent;
border: none;
+}
+
+table.board-list-table .board-tags .board-cell:hover {
+ line-height: 27px;
+ background: #EEEEEE;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #DDDDDD;
}
\ No newline at end of file
diff --git a/stylesheets/redchanit.css b/stylesheets/redchanit.css
index 78456f31..51ae7f9c 100644
--- a/stylesheets/redchanit.css
+++ b/stylesheets/redchanit.css
@@ -81,9 +81,17 @@ table tbody tr:nth-of-type( even ) {
}
table.board-list-table .board-uri .board-sfw {
- color: #D00;
+ color: #8020FF;
}
tbody.board-list-omitted td {
background: #343C4E;
border: none;
+}
+
+table.board-list-table .board-tags .board-cell:hover {
+ line-height: 24px;
+ background: #3B4357;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #343C4E;
}
\ No newline at end of file
diff --git a/stylesheets/style.css b/stylesheets/style.css
index fef7120e..2a805d16 100644
--- a/stylesheets/style.css
+++ b/stylesheets/style.css
@@ -1448,6 +1448,16 @@ table.board-list-table {
table-layout: fixed;
}
+table.board-list-table .board-cell {
+ position: static;
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
table.board-list-table .board-meta {
padding-right: 4px;
width: 70px;
@@ -1471,9 +1481,25 @@ table.board-list-table .board-unique {
padding: 4px;
}
table.board-list-table .board-tags {
+ position: relative;
+ height: 15px;
width: auto;
padding: 0 15px 0 4px;
}
+table.board-list-table .board-tags .tag-link {
+ display: inline;
+}
+table.board-list-table .board-tags .board-cell:hover {
+ position: absolute;
+ background: #EEF2FF;
+ line-height: 23px;
+ top: 0;
+ bottom: 0;
+ width: 310px;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #D6DAF0;
+}
table.board-list-table .board-uri .board-nsfw {
color: rgb(230,0,0);
@@ -1481,8 +1507,7 @@ table.board-list-table .board-uri .board-nsfw {
float: right;
}
table.board-list-table .board-uri .board-sfw {
- /* I'm using blue instead of green to help users with Deuteranopia (most common form of colorblndness). */
- color: rgb(0,0,230);
+ color: #34345C;
margin: 0 0 0 0.6em;
float: right;
}
diff --git a/stylesheets/tomorrow.css b/stylesheets/tomorrow.css
index 17b95957..c8a4427e 100644
--- a/stylesheets/tomorrow.css
+++ b/stylesheets/tomorrow.css
@@ -57,7 +57,7 @@ p.intro span.subject {
p.intro span.name {
color:#C5C8C6
}
-span.quote {
+.quote {
color:#adbd68
}
span.heading {
@@ -179,9 +179,16 @@ table tbody tr:nth-of-type( even ) {
}
table.board-list-table .board-uri .board-sfw {
- color: #C5C8C6;
+ color: #81a2be;
}
tbody.board-list-omitted td {
background: #282a2e;
border-color: #111;
+}
+
+table.board-list-table .board-tags .board-cell:hover {
+ background: #1d1f21;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #282a2e;
}
\ No newline at end of file
diff --git a/stylesheets/yotsuba.css b/stylesheets/yotsuba.css
index 34e4d079..f5b0540b 100644
--- a/stylesheets/yotsuba.css
+++ b/stylesheets/yotsuba.css
@@ -94,4 +94,11 @@ table.board-list-table .board-uri .board-sfw {
tbody.board-list-omitted td {
background: #fca;
border-color: #800;
+}
+
+table.board-list-table .board-tags .board-cell:hover {
+ background: #ffe;
+}
+table.board-list-table tr:nth-of-type( even ) .board-tags .board-cell {
+ background: #ede2d4;
}
\ No newline at end of file
diff --git a/templates/8chan/boards-search.html b/templates/8chan/boards-search.html
index e4d70032..7c2191b5 100644
--- a/templates/8chan/boards-search.html
+++ b/templates/8chan/boards-search.html
@@ -62,24 +62,32 @@
+
-
+
-
+
- |
+
{% trans %}Board{% endtrans %} |
{% trans %}Title{% endtrans %} |
{% trans %}PPH{% endtrans %} |
- {% trans %}Total posts{% endtrans %} |
{% trans %}Active users{% endtrans %} |
{% trans %}Tags{% endtrans %} |
+ {% trans %}Total posts{% endtrans %} |
@@ -87,13 +95,13 @@
- |
+ |
- Displaying results {{search.page + 1}} through {{ boards|count + search.page}} out of {{ boards|count + boards_omitted }}. Click to load more. |
+ Displaying results {{search.page + 1}} through {{ boards|count + search.page}} out of {{ boards|count + boards_omitted }}. Click to load more. |
{% if boards_omitted > 0 %}
|