From 32061668a320aa929c59a17a3af5db4d4a90cb69 Mon Sep 17 00:00:00 2001
From: 8n-tech <8n-tech@users.noreply.github.com>
Date: Sun, 19 Apr 2015 13:10:13 +1000
Subject: [PATCH] #456 #458 - Completed language support on boards list. #461 -
"Post a reply" button JS added.
Signed-off-by: 8n-tech <8n-tech@users.noreply.github.com>
---
board-search.php | 18 ++++++++----------
boards.php | 11 +++--------
inc/functions.php | 2 +-
inc/instance-config.php | 26 ++++++++++++++++++++++++++
js/quick-post-controls.js | 11 +++++++++--
stylesheets/style.css | 2 +-
templates/8chan/boards-search.html | 4 +++-
7 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/board-search.php b/board-search.php
index 74272b35..a02c89bf 100644
--- a/board-search.php
+++ b/board-search.php
@@ -14,13 +14,6 @@ $CanViewUnindexed = isset($mod["type"]) && $mod["type"] <= GlobalVolunteer;
$response = array();
-/* Prefetch some information. */
-$languages = array(
- "en",
- "es",
-);
-
-
/* Determine search parameters from $_GET */
$search = array(
'lang' => false,
@@ -48,7 +41,7 @@ if (isset( $_GET['page'] ) && $_GET['page'] != "") {
}
// Include what language (if the language is not blank and we recognize it)?
-if (isset( $_GET['lang'] ) && $_GET['lang'] != "" && isset($languages[$search['lang']])) {
+if (isset( $_GET['lang'] ) && $_GET['lang'] != "" && isset($config['languages'][$_GET['lang']])) {
$search['lang'] = $_GET['lang'];
}
@@ -116,11 +109,16 @@ foreach ($boards as $board) {
$boardLang = strtolower( array_slice( explode( "_", $boardConfig['locale'] ?: "" ), 0 )[0] ); // en_US -> en OR en -> en
// Check against our config search options.
- if ( $search['lang'] !== false && $search['lang'] != $boardLang ) {
+ if ($search['lang'] !== false && $search['lang'] != $boardLang) {
continue;
}
- $board['locale'] = $boardLang;
+ if (isset($config['languages'][$boardLang])) {
+ $board['locale'] = $config['languages'][$boardLang];
+ }
+ else {
+ $board['locale'] = $boardLang;
+ }
$response['boards'][ $board['uri'] ] = $board;
}
diff --git a/boards.php b/boards.php
index c85346e8..0acdfaf5 100644
--- a/boards.php
+++ b/boards.php
@@ -1,7 +1,6 @@
$config,
"boards" => $boards,
@@ -73,6 +67,7 @@ $searchHTML = Element("8chan/boards-search.html", array(
"boards" => $boards,
"tags" => $tags,
"search" => $searchJson['search'],
+ "languages" => $config['languages'],
"boards_total" => $boards_total,
"boards_public" => $boards_public,
diff --git a/inc/functions.php b/inc/functions.php
index b2d01da4..8a279b41 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -822,7 +822,7 @@ function loadBoardConfig( $uri ) {
$config = array(
"locale" => "en_US",
);
- $configPath = "/{$uri}/config.php";
+ $configPath = "./{$uri}/config.php";
if (file_exists( $configPath ) && is_readable( $configPath )) {
include( $configPath );
diff --git a/inc/instance-config.php b/inc/instance-config.php
index 099b7bd2..c6fb8cea 100644
--- a/inc/instance-config.php
+++ b/inc/instance-config.php
@@ -185,6 +185,32 @@
'message' => 'On this board, to prevent raids the number of threads that can be created per hour is limited. Please try again later, or post in an existing thread.'
);
+ $config['languages'] = array(
+ 'ch' => "汉语",
+ 'cz' => "Čeština",
+ 'dk' => "Dansk",
+ 'de' => "Deutsch",
+ 'eo' => "Esperanto",
+ 'en' => "English",
+ 'es' => "Español",
+ 'fi' => "Suomi",
+ 'fr' => "Français",
+ 'hu' => "Magyar",
+ 'it' => "Italiano",
+ 'jp' => "日本語",
+ 'jbo' => "Lojban",
+ 'lt' => "Lietuvių Kalba",
+ 'lv' => "Latviešu Valoda",
+ 'no' => "Norsk",
+ 'nl' => "Nederlands Vlaams",
+ 'pl' => "Polski",
+ 'pt' => "Português",
+ 'ru' => "Русский",
+ 'sk' => "Slovenský Jazyk",
+ 'tw' => "Taiwanese",
+ );
+
+
$config['gzip_static'] = false;
$config['hash_masked_ip'] = true;
$config['force_subject_op'] = false;
diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js
index 4e8df1cb..67c4bc51 100644
--- a/js/quick-post-controls.js
+++ b/js/quick-post-controls.js
@@ -90,5 +90,12 @@ $(document).ready(function(){
$(document).on('new_post', function(e, post) {
$(post).find('input[type=checkbox].delete').each(init_qpc);
});
-});
-
+
+ // Bottom of the page quick reply function
+ $("#thread-quick-reply").show();
+ $("#link-quick-reply").on( 'click', function(event) {
+ event.preventDefault();
+ $(window).trigger('cite', ['']);
+ return false;
+ } );
+} );
\ No newline at end of file
diff --git a/stylesheets/style.css b/stylesheets/style.css
index b930a4c4..a46677bb 100644
--- a/stylesheets/style.css
+++ b/stylesheets/style.css
@@ -1443,7 +1443,7 @@ table.board-list-table {
table.board-list-table .board-meta {
padding-right: 4px;
- width: 44px;
+ width: 70px;
}
table.board-list-table .board-uri {
max-width: 196px;
diff --git a/templates/8chan/boards-search.html b/templates/8chan/boards-search.html
index d8bbbeb3..e4d70032 100644
--- a/templates/8chan/boards-search.html
+++ b/templates/8chan/boards-search.html
@@ -28,7 +28,9 @@