From 2d6d449bd2d720241b5774f403d08167bfa25e7c Mon Sep 17 00:00:00 2001 From: unknown <8n-tech@users.noreply.github.com> Date: Sat, 18 Oct 2014 20:07:04 -0500 Subject: [PATCH] [#184] Added tag classes. Style selector now adds a class. Moved board list under moderator dashboard. --- d | 553 ++++++++++++++++++++++++++++++ inc/instance-config.php | 14 +- inc/mod/pages.php | 210 ++++++++---- install.php | 32 +- stylesheets/style.css | 2 +- templates/8chan/index.html | 2 +- templates/generic_page.html | 2 +- templates/index.html | 2 +- templates/main.js | 100 ++++-- templates/mod/dashboard.html | 170 ++++----- templates/mod/report.html | 42 +-- templates/mod/reports.html | 4 +- templates/page.html | 3 +- templates/post_thread.html | 2 +- templates/themes/basic/index.html | 2 +- templates/thread.html | 2 +- 16 files changed, 915 insertions(+), 227 deletions(-) create mode 100644 d diff --git a/d b/d new file mode 100644 index 00000000..09ddbcc5 --- /dev/null +++ b/d @@ -0,0 +1,553 @@ +diff --git a/inc/instance-config.php b/inc/instance-config.php +index 699d1a1..475f3ed 100644 +--- a/inc/instance-config.php ++++ b/inc/instance-config.php +@@ -18,15 +18,15 @@ + $config['db']['user'] = 'root'; + $config['db']['password'] = ''; + $config['timezone'] = 'UTC'; +- $config['cache']['enabled'] = 'apc'; +- +- ++ $config['cache']['enabled'] = false; ++  ++  + $config['cookies']['mod'] = 'mod'; + $config['cookies']['salt'] = ''; +- ++  + $config['spam']['hidden_inputs_max_pass'] = 128; + $config['spam']['hidden_inputs_expire'] = 60 * 60 * 4; // three hours +- ++  + $config['flood_time'] = 5; + $config['flood_time_ip'] = 30; + $config['flood_time_same'] = 2; +@@ -46,10 +46,10 @@ + $config['thread_subject_in_title'] = true; + $config['spam']['hidden_inputs_max_pass'] = 128; + $config['ayah_enabled'] = true; +- ++  + // Load database credentials + require "secrets.php"; +- ++  + // Image shit + $config['thumb_method'] = 'gm+gifsicle'; + $config['thumb_ext'] = ''; +diff --git a/install.php b/install.php +index 8b3815a..07e94e7 100644 +--- a/install.php ++++ b/install.php +@@ -579,7 +579,8 @@ if ($step == 0) { +

'; +  + echo Element('page.html', $page); +-} elseif ($step == 1) { ++} ++elseif ($step == 1) { + $page['title'] = 'Pre-installation test'; +  + $can_exec = true; +@@ -761,7 +762,8 @@ if ($step == 0) { + 'title' => 'Checking environment', + 'config' => $config + )); +-} elseif ($step == 2) { ++} ++elseif ($step == 2) { + // Basic config + $page['title'] = 'Configuration'; +  +@@ -775,7 +777,8 @@ if ($step == 0) { + 'title' => 'Configuration', + 'config' => $config + )); +-} elseif ($step == 3) { ++} ++elseif ($step == 3) { + $instance_config =  + 'I couldn\'t write to inc/instance-config.php with the new configuration, probably due to a permissions error.

 +@@ -826,7 +830,8 @@ if ($step == 0) { + '; + echo Element('page.html', $page); + } +-} elseif ($step == 4) { ++} ++elseif ($step == 4) { + // SQL installation +  + buildJavascript(); +@@ -846,11 +851,15 @@ if ($step == 0) { +  + $sql_errors = ''; + foreach ($queries as $query) { +- if ($mysql_version < 50503) ++ if ($mysql_version < 50503) { + $query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query); ++ } ++  + $query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query); +- if (!query($query)) ++  ++ if (!query($query)) { + $sql_errors .= '
  • ' . db_error() . '
  • '; ++ } + } +  + $page['title'] = 'Installation complete'; +@@ -858,7 +867,8 @@ if ($step == 0) { +  + if (!empty($sql_errors)) { + $page['body'] .= '

    SQL errors

    SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a vichan installation; if so, you can probably ignore this.

    The errors encountered were:

    Ignore errors and complete installation.

    '; +- } else { ++ } ++ else { + $boards = listBoards(); + foreach ($boards as &$_board) { + setupBoard($_board); +@@ -866,13 +876,11 @@ if ($step == 0) { + } +  + file_write($config['has_installed'], VERSION); +- /*if (!file_unlink(__FILE__)) { +- $page['body'] .= '

    Delete install.php!

    I couldn\'t remove install.php. You will have to remove it manually.

    '; +- }*/ + } +  + echo Element('page.html', $page); +-} elseif ($step == 5) { ++} ++elseif ($step == 5) { + $page['title'] = 'Installation complete'; + $page['body'] = '

    Thank you for using vichan. Please remember to report any bugs you discover.

    '; +  +diff --git a/templates/8chan/index.html b/templates/8chan/index.html +index 459e7e8..4f25473 100644 +--- a/templates/8chan/index.html ++++ b/templates/8chan/index.html +@@ -223,7 +223,7 @@ +  +  +  +-  ++  +  +
     +  +diff --git a/templates/generic_page.html b/templates/generic_page.html +index 0fe1f9c..4cd3116 100644 +--- a/templates/generic_page.html ++++ b/templates/generic_page.html +@@ -6,7 +6,7 @@ + {{ board.url }} - {{ board.name }} + {% endblock %} +  +-  ++ + {{ boardlist.top }} + {% if pm %}
    You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

    {% endif %} + {% if config.url_banner %}{% endif %} +diff --git a/templates/index.html b/templates/index.html +index aae87c1..5638fd6 100644 +--- a/templates/index.html ++++ b/templates/index.html +@@ -14,7 +14,7 @@ + {% include 'header.html' %} + {{ board.url }} - {{ board.title|e }} +  +-  ++ + {{ boardlist.top }} +  + {% if pm %}
    You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

    {% endif %} +diff --git a/templates/main.js b/templates/main.js +index 1ec4d26..d100f93 100644 +--- a/templates/main.js ++++ b/templates/main.js +@@ -73,11 +73,6 @@ var saved = {}; +  +  + var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0|addslashes }}{% raw %}'; +-/*var styles = { +- {% endraw %} +- {% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}', +- {% endraw %}{% endfor %}{% raw %} +-};*/ + var board_name = false; +  + function changeStyle(styleName, link) { +@@ -92,36 +87,78 @@ function changeStyle(styleName, link) { + {% endif %} + {% raw %} +  +- if (!document.getElementById('stylesheet')) { +- var s = document.createElement('link'); +- s.rel = 'stylesheet'; +- s.type = 'text/css'; +- s.id = 'stylesheet'; ++ // Find the for the stylesheet. May be nothing. ++ var domStylesheet = document.getElementById('stylesheet'); ++ // Determine if this stylesheet is the default. ++ var setToDefault = ( styles[styleName] == "" || styles[styleName] == "/stylesheets/" ); ++ // Turn "Yotsuba B" to "yotsuba_b"  ++ var attributeName = styleName.replace(/[^a-z0-9_\-]/gi, '_').toLowerCase(); ++  ++ if( !domStylesheet && !setToDefault ) { ++ domStylesheet = document.createElement('link'); ++ domStylesheet.rel = 'stylesheet'; ++ domStylesheet.type = 'text/css'; ++ domStylesheet.id = 'stylesheet'; ++  + var x = document.getElementsByTagName('head')[0]; +- x.appendChild(s); ++ x.appendChild(domStylesheet); + } +- +- {% endraw %} +- var root = "{{ config.root }}"; +- {% raw %} +- root = root.replace(/\/$/, ""); +-  +- document.getElementById('stylesheet').href = root + styles[styleName]; +- selectedstyle = styleName; +  +- if (document.getElementsByClassName('styles').length != 0) { +- var styleLinks = document.getElementsByClassName('styles')[0].childNodes; +- for (var i = 0; i < styleLinks.length; i++) { +- styleLinks[i].className = ''; ++ if( !setToDefault ) { ++ {% endraw %} ++ var root = "{{ config.root }}"; ++ {% raw %} ++ root = root.replace(/\/$/, ""); ++  ++ domStylesheet.href = root + styles[styleName]; ++ selectedstyle = styleName; ++  ++ if (document.getElementsByClassName('styles').length != 0) { ++ var styleLinks = document.getElementsByClassName('styles')[0].childNodes; ++ for (var i = 0; i < styleLinks.length; i++) { ++ styleLinks[i].className = ''; ++ } + } ++  ++ if (link) { ++ link.className = 'selected'; ++ } ++ } ++ else if( domStylesheet ) { ++ domStylesheet.parentNode.removeChild( domStylesheet ); + } +  +- if (link) { +- link.className = 'selected'; ++ // Fix the classes on the body tag. ++ var body = document.getElementsByTagName('body')[0]; ++  ++ if( body ) { ++ var bodyClasses = document.getElementsByTagName('body')[0].getAttribute('class').split(" "); ++ var bodyClassesNew = []; ++  ++ for( i = 0; i < bodyClasses.length; ++i ) { ++ var bodyClass = bodyClasses[ i ]; ++  ++ // null class from a double-space. ++ if( bodyClass == "" ) { ++ continue; ++ } ++  ++ if( bodyClass.indexOf( "stylesheet-" ) == 0 ) { ++ continue; ++ } ++  ++ bodyClassesNew.push( bodyClass ); ++ } ++  ++ // Add stylesheet-yotsuba_b at the end. ++ bodyClassesNew.push( "stylesheet-" + attributeName ); ++ body.setAttribute( 'class', bodyClassesNew.join(" ") ); ++ body.setAttribute( 'data-stylesheet', attributeName ); + } +  +- if (typeof $ != 'undefined') ++ if (typeof $ != 'undefined') { + $(window).trigger('stylesheet', styleName); ++ } + } +  +  +@@ -167,7 +204,7 @@ function init_stylechooser() { + } + } + } +- {% endraw%} ++ {% endraw %} + {% else %} + {% raw %} + if (localStorage.stylesheet) { +@@ -185,10 +222,13 @@ function init_stylechooser() { +  + function get_cookie(cookie_name) { + var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); +- if (results) ++  ++ if (results) { + return (unescape(results[2])); +- else ++ } ++ else { + return null; ++ } + } +  + function highlightReply(id) { +diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html +index 4f76625..87e67c8 100644 +--- a/templates/mod/dashboard.html ++++ b/templates/mod/dashboard.html +@@ -1,40 +1,5 @@ +-
     +- {% trans 'Boards' %} +-  +-
       +- {% for board in boards %} +- {% if board.uri in mod.boards or mod.boards[0] == '*' %} +-
    •  +- {{ config.board_abbreviation|sprintf(board.uri) }} +- -  +- {{ board.title|e }} +- {% if board.subtitle %} +- —  +- {% if config.allow_subtitle_html %} +- {{ board.subtitle }} +- {% else %} +- {{ board.subtitle|e }} +- {% endif %} +-  +- +- {% endif %} +- {% if mod.type == "20" %} +- [{% trans 'settings' %}] +- {% endif %} +- {% if mod|hasPermission(config.mod.manageboards) %} +- [{% trans 'edit' %}] +- {% endif %} +-
    •  +- {% endif %} +- {% endfor %} +-  +- {% if mod|hasPermission(config.mod.newboard) %} +-
    • {% trans 'Create new board' %}
    •  +- {% endif %} +-
     +-
     +- +-
     ++ ++
     + {% trans 'Messages' %} +
       + {% if mod|hasPermission(config.mod.noticeboard) %} +@@ -78,7 +43,8 @@ +
     +
     +  +-
     ++ ++
     + {% trans 'Administration' %} +  +
       +@@ -123,57 +89,99 @@ +
     +
     +  ++ + {% if mod|hasPermission(config.mod.search) %} +-
     +- {% trans 'Search' %} +-  +-
       ++ ++{% endif %} ++ ++ ++
       ++ {% trans 'Boards' %} ++  ++ 
         ++ {% for board in boards %} ++ {% if board.uri in mod.boards or mod.boards[0] == '*' %} +
      •  +- {% include 'mod/search_form.html' %} ++ {{ config.board_abbreviation|sprintf(board.uri) }} ++  -  ++ {{ board.title|e }} ++ {% if board.subtitle %} ++ —  ++ {% if config.allow_subtitle_html %} ++ {{ board.subtitle }} ++ {% else %} ++ {{ board.subtitle|e }} ++ {% endif %} ++  ++ ++ {% endif %} ++ {% if mod.type == "20" %} ++ [{% trans 'settings' %}] ++ {% endif %} ++ {% if mod|hasPermission(config.mod.manageboards) %} ++  [{% trans 'edit' %}] ++ {% endif %} +
      •  +-
       +-
       +-{% endif %} ++ {% endif %} ++ {% endfor %} ++  ++ {% if mod|hasPermission(config.mod.newboard) %} ++ 
    • {% trans 'Create new board' %}
    •  ++ {% endif %} ++ 
     ++
     +  ++ + {% if config.mod.dashboard_links|count %} +-
     +- {% trans 'Other' %} +-  +-
       +- {% for label,link in config.mod.dashboard_links %} +-
    • {{ label }}
    •  +- {% endfor %} +-
     +-
     ++
     ++ {% trans 'Other' %} ++ ++ 
       ++ {% for label,link in config.mod.dashboard_links %} ++ 
    • {{ label }}
    •  ++ {% endfor %} ++ 
     ++
     + {% endif %} +  ++ + {% if config.debug %} +-
     +- {% trans 'Debug' %} +-  +-
     ++
     ++ {% trans 'Debug' %} ++  ++
     + {% endif %} +  ++ + {% if newer_release %} +-
     +- Update +-
       +-
    •  +- A newer version of Tinyboard  +- (v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}) is available!  +- See http://tinyboard.org/ for upgrade instructions. +-
    •  +-
     +-
     ++
     ++ Update ++ 
       ++ 
    •  ++ A newer version of Tinyboard  ++ (v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}) is available!  ++ See http://tinyboard.org/ for upgrade instructions. ++ 
    •  ++ 
     ++
     + {% endif %} +  +-
     ++ ++ + + +{% if config.mod.dashboard_links|count %} +
    + {% trans 'Other' %} + +
      + {% for label,link in config.mod.dashboard_links %} +
    • {{ label }}
    • + {% endfor %} +
    +
    {% endif %} -
    + +{% if config.debug %} +
    + {% trans 'Debug' %} + +
    +{% endif %} + + +{% if newer_release %} +
    + Update +
      +
    • + A newer version of Tinyboard + (v{{ newer_release.massive }}.{{ newer_release.major }}.{{ newer_release.minor }}) is available! + See http://tinyboard.org/ for upgrade instructions. +
    • +
    +
    +{% endif %} + + +