diff --git a/inc/config.php b/inc/config.php index 9aa83e8f..34a72ce4 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1921,3 +1921,7 @@ //Empty board alias $config['boards_alias'] = array(); + + //Logo location for themes + $config['logo'] = 'static/logo.png'; + diff --git a/inc/instance-config.php b/inc/instance-config.php index fa838fc5..a5b18a43 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -109,6 +109,9 @@ $config['secure_trip_salt'] = 'ODQ2NDM0ODlmMmRhNzk2M2EyNjJlOW'; //Banners $config['url_banner'] = '/banners.php'; +//Logo location for themes +$config['logo'] = 'static/leftypol_logo.png'; + //Date format $config['post_date'] = '%F (%a) %T'; @@ -370,6 +373,7 @@ $config['additional_javascript'][] = 'js/auto-reload.js'; $config['additional_javascript'][] = 'js/auto-scroll.js'; $config['additional_javascript'][] = 'js/thread-stats.js'; $config['additional_javascript'][] = 'js/post-hover.js'; +$config['additional_javascript'][] = 'js/image-hover.js'; $config['additional_javascript'][] = 'js/style-select.js'; $config['additional_javascript'][] = 'js/flag-preview.js'; @@ -394,7 +398,6 @@ $config['additional_javascript'][] = 'js/file-selector.js'; $config['additional_javascript'][] = 'js/save-user_flag.js'; $config['additional_javascript'][] = 'js/webm-settings.js'; $config['additional_javascript'][] = 'js/expand-video.js'; -$config['additional_javascript'][] = 'js/download-original.js'; $config['flag_preview'] = true; diff --git a/js/catalog-search.js b/js/catalog-search.js index fc39b1ce..34196210 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -59,7 +59,8 @@ var searchThreads = function($threads, query) { // Only load in the catalog if (active_page == 'catalog') { - onready(catalogSearch); + + $(document).ready(catalogSearch); } }()); diff --git a/js/download-original.js b/js/download-original.js index cf9635ac..9fde68f5 100644 --- a/js/download-original.js +++ b/js/download-original.js @@ -15,7 +15,7 @@ * */ -onready(function(){ +$(document).ready(function(){ var do_original_filename = function() { var filename, truncated; if ($(this).attr('title')) { diff --git a/js/expand-all-images.js b/js/expand-all-images.js index c110f51c..64394beb 100644 --- a/js/expand-all-images.js +++ b/js/expand-all-images.js @@ -17,7 +17,7 @@ */ if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index') -onready(function(){ +$(document).ready(function(){ $('hr:first').before('
'); $('div#expand-all-images a') .text(_('Expand all images')) diff --git a/js/expand-video.js b/js/expand-video.js index eb26cbed..421676c4 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -216,7 +216,7 @@ function setupVideosIn(element) { } } -onready(function(){ +$(document).ready(function(){ // Insert menu from settings.js if (typeof settingsMenu != "undefined" && typeof Options == "undefined") { var firsthr = document.getElementsByTagName("hr")[0]; diff --git a/js/file-selector.js b/js/file-selector.js index c2b5381b..f90bfd3b 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -8,24 +8,6 @@ */ function init_file_selector(max_images) { -$(document).ready(function () { - // add options panel item - if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); - - if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); - } -}); - // disabled by user, or incompatible browser. if (localStorage.file_dragdrop == 'false' || !(window.URL.createObjectURL && window.File)) return; @@ -190,3 +172,26 @@ $(document).on('paste', function (e) { }); } + +$(document).ready(function () { + // add options panel item + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); + + if (typeof localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); + +$(document).ready(function () { + var maxImages = document.querySelector("form[name=post]").dataset.maxImages; + init_file_selector(Number(maxImages)); +}); diff --git a/js/flag-preview.js b/js/flag-preview.js index c7a6b986..6a4d8943 100644 --- a/js/flag-preview.js +++ b/js/flag-preview.js @@ -26,7 +26,7 @@ function updatePreviewWithSelected(img, select) { img.attr("src", getFlagUrl(select.find(":selected").val())); } -onready(function(){ +$(document).ready(function(){ var flagImg = $('#flag_preview'); var flagSelect = $('#user_flag'); var loaded = loadFlag(); diff --git a/js/image-hover.js b/js/image-hover.js index 3e294d1c..e639eec3 100644 --- a/js/image-hover.js +++ b/js/image-hover.js @@ -4,10 +4,9 @@ * I also changed initHover() to also bind on new_post. * Thanks Pashe for using WTFPL. */ - + if (active_page === "catalog" || active_page === "thread" || active_page === "index" || active_page === "ukko") { -$(document).on('ready', function(){ - +$(document).ready(function () { if (window.Options && Options.get_tab('general')) { Options.extend_tab("general", "
Image hover" @@ -19,7 +18,6 @@ if (window.Options && Options.get_tab('general')) { $('.image-hover').on('change', function(){ var setting = $(this).attr('id'); - localStorage[setting] = $(this).children('input').is(':checked'); }); @@ -34,6 +32,7 @@ if (getSetting('catalogImageHover')) $('#catalogImageHover>input').prop('checked if (getSetting('imageHoverFollowCursor')) $('#imageHoverFollowCursor>input').prop('checked', 'checked'); function getFileExtension(filename) { //Pashe, WTFPL + if (filename == undefined) {return "unknown";} // catalog if (filename.match(/\.([a-z0-9]+)(&loop.*)?$/i) !== null) { return filename.match(/\.([a-z0-9]+)(&loop.*)?$/i)[1]; } else if (filename.match(/https?:\/\/(www\.)?youtube.com/)) { @@ -96,38 +95,41 @@ function initImageHover() { //Pashe, influenced by tux, et al, WTFPL }); } +function followCursor(e, hoverImage) { + var scrollTop = $(window).scrollTop(); + var imgWidth = Number(hoverImage.css("max-width").slice(0,-2)) + var imgHeight = Number(hoverImage.css("max-height").slice(0,-2)) + var imgTop = e.pageY - (imgHeight/2); + var windowWidth = $(window).width(); + var imgEnd = imgWidth + e.pageX; + + if (imgTop < scrollTop + 15) { + imgTop = scrollTop + 15; + } else if (imgTop > scrollTop + $(window).height() - imgHeight - 15) { + imgTop = scrollTop + $(window).height() - imgHeight - 15; + } + + if (imgEnd > windowWidth) { + hoverImage.css({ + 'left': (e.pageX + (windowWidth - imgEnd)), + 'top' : imgTop, + }); + } else { + hoverImage.css({ + 'left': e.pageX, + 'top' : imgTop, + }); + } +} + function imageHoverStart(e) { //Pashe, anonish, WTFPL var hoverImage = $("#chx_hoverImage"); - - if (hoverImage.length) { + + if (hoverImage.length){ if (getSetting("imageHoverFollowCursor")) { - var scrollTop = $(window).scrollTop(); - var imgY = e.pageY; - var imgTop = imgY; - var windowWidth = $(window).width(); - var imgWidth = hoverImage.width() + e.pageX; - - if (imgY < scrollTop + 15) { - imgTop = scrollTop; - } else if (imgY > scrollTop + $(window).height() - hoverImage.height() - 15) { - imgTop = scrollTop + $(window).height() - hoverImage.height() - 15; - } - - if (imgWidth > windowWidth) { - hoverImage.css({ - 'left': (e.pageX + (windowWidth - imgWidth)), - 'top' : imgTop, - }); - } else { - hoverImage.css({ - 'left': e.pageX, - 'top' : imgTop, - }); - } - + followCursor(e, hoverImage); hoverImage.appendTo($("body")); - } - + } return; } @@ -145,8 +147,8 @@ function imageHoverStart(e) { //Pashe, anonish, WTFPL hoverImage = $(''); - if (getSetting("imageHoverFollowCursor")) { - var size = $this.parents('.file').find('.unimportant').text().match(/\b(\d+)x(\d+)\b/), + if (getSetting("imageHoverFollowCursor") && active_page !== "catalog") { + var size = $this.parents('.file').find('.details').text().match(/\b(\d+)x(\d+)\b/), maxWidth = $(window).width(), maxHeight = $(window).height(); @@ -159,8 +161,6 @@ function imageHoverStart(e) { //Pashe, anonish, WTFPL "height" : size[2] + "px", "max-width" : (size[1] * scale) + "px", "max-height" : (size[2] * scale) + "px", - 'left' : e.pageX, - 'top' : imgTop, }); } else { hoverImage.css({ @@ -173,7 +173,13 @@ function imageHoverStart(e) { //Pashe, anonish, WTFPL "max-height" : "100%", }); } + + if (getSetting("imageHoverFollowCursor")) { + followCursor(e, hoverImage); + } + hoverImage.appendTo($("body")); + if (isOnThread()) {$this.css("cursor", "none");} } @@ -185,3 +191,4 @@ initImageHover(); }); } + diff --git a/js/inline-expanding-filename.js b/js/inline-expanding-filename.js index ac79fcf0..fd618296 100644 --- a/js/inline-expanding-filename.js +++ b/js/inline-expanding-filename.js @@ -13,7 +13,7 @@ * */ -onready(function(){ +$(document).ready(function(){ var inline_expanding_filename = function() { $(this).find(".fileinfo > a").click(function(){ var imagelink = $(this).parent().parent().find('a[target="_blank"]:first'); diff --git a/js/post-hover.js b/js/post-hover.js index b9987c8e..6ecd4c21 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -13,7 +13,7 @@ * */ -onready(function(){ +$(document).ready(function () { var dont_fetch_again = []; init_hover = function() { var $link = $(this); diff --git a/js/show-backlinks.js b/js/show-backlinks.js index fa4865fd..d32cf803 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -13,7 +13,7 @@ * */ -onready(function(){ +$(document).ready(function(){ var showBackLinks = function() { var reply_id = $(this).attr('id').replace(/^reply_/, ''); diff --git a/js/smartphone-spoiler.js b/js/smartphone-spoiler.js index 05273c19..aa7f4b0a 100644 --- a/js/smartphone-spoiler.js +++ b/js/smartphone-spoiler.js @@ -12,7 +12,7 @@ * */ -onready(function(){ +$(document).ready(function(){ if(device_type == 'mobile') { var fix_spoilers = function(where) { var spoilers = where.getElementsByClassName('spoiler'); diff --git a/js/style-select.js b/js/style-select.js index e9d395f0..485da735 100644 --- a/js/style-select.js +++ b/js/style-select.js @@ -14,32 +14,42 @@ * */ -onready(function(){ - var stylesDiv = $('div.styles'); - var pages = $('div.pages'); - var stylesSelect = $(''); - - var i = 1; - stylesDiv.children().each(function() { - var opt = $('') - .html(this.innerHTML.replace(/(^\[|\]$)/g, '')) - .val(i); - if ($(this).hasClass('selected')) - opt.attr('selected', true); - stylesSelect.append(opt); - $(this).attr('id', 'style-select-' + i); - i++; - }); - - stylesSelect.change(function() { - $('#style-select-' + $(this).val()).click(); - }); - - stylesDiv.hide() - pages.after( - $('
') - /*.text(_('Style: '))*/ - .append(stylesSelect) - ); -}); +$(document).ready(function() { + var stylesDiv = $('div.styles'); + var pages = $('div.pages'); + var stylesSelect = $('').css({float:"none"}); + var options = []; + + var i = 1; + stylesDiv.children().each(function() { + var name = this.innerHTML.replace(/(^\[|\]$)/g, ''); + var opt = $('') + .html(name) + .val(i); + if ($(this).hasClass('selected')) + opt.attr('selected', true); + options.push ([name.toUpperCase (), opt]); + $(this).attr('id', 'style-select-' + i); + i++; + }); + options.sort ((a, b) => { + const keya = a [0]; + const keyb = b [0]; + if (keya < keyb) { return -1; } + if (keya > keyb) { return 1; } + return 0; + }).forEach (([key, opt]) => { + stylesSelect.append(opt); + }); + + stylesSelect.change(function() { + $('#style-select-' + $(this).val()).click(); + }); + + stylesDiv.hide() + pages.after( + $('
') + .append(_('Select theme: '), stylesSelect) + ); +}); diff --git a/js/youtube.js b/js/youtube.js index dc83d10f..414e0bab 100644 --- a/js/youtube.js +++ b/js/youtube.js @@ -23,7 +23,7 @@ */ -onready(function(){ +$(document).ready(function(){ const ON = "[Remove]"; const OFF = "[Embed]"; diff --git a/post.php b/post.php index 2f1d5798..f794d917 100644 --- a/post.php +++ b/post.php @@ -280,7 +280,8 @@ function handle_delete(){ $root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root']; if (!isset($_POST['json_response'])) { - header('Location: ' . $root . $board['dir'] . $config['file_index'], true, $config['redirect_http']); + // If only deleting a post in a thread, redirect to the current thread + header('Location: ' . $root . $board['dir'] . ($post['thread'] ? $config['dir']['res'] . sprintf($config['file_page'], $post['thread']) : $config['file_index']), true, $config['redirect_http']); } else { header('Content-Type: text/json'); echo json_encode(array('success' => true)); diff --git a/status.php b/status.php index ef2e28f8..7b326de9 100644 --- a/status.php +++ b/status.php @@ -49,6 +49,52 @@ foreach ($board_list as $board) { ]; } +function endsWith( $haystack, $needle ) { + $length = strlen( $needle ); + if( !$length ) { + return true; + } + return substr( $haystack, -$length ) === $needle; +} + +// Boards that are nsfw +$nsfw_boards = ['b', 'overboard']; +// Boards that use spoiler_alunya.png as their spoiler +$alunya_spoiler = ['leftypol', 'anime']; +// Boards where posts are not allowed to be created +$readonly_boards = ['overboard', 'sfw', 'alt']; + +$board_list = listBoards(); + +// Add objects that are not boards but are treated as such +$board_list[] = ['uri' => 'overboard', 'title' => 'Overboard']; +$board_list[] = ['uri' => 'sfw', 'title' => 'SFW Overboard']; +$board_list[] = ['uri' => 'alt', 'title' => 'Alternate Overboard']; + +/** + * Allowed fields for the board object: + * - code: The board code ('b', 'tech', ...) + * - name: The board user-readable name ('Siberia', ...) + * - description: The board description ('Leftist Politically Incorrect', ...) + * - sfw: Is this board sfw? + * - alternate_spoilers: Does this board use the alunya spoiler? + */ +$boards = []; +foreach ($board_list as $board) { + // Skip archives + if (endsWith($board['uri'], '_archive')) { + continue; + } + + $boards[] = [ + 'code' => $board['uri'], + 'name' => $board['title'], + 'sfw' => !in_array($board['uri'], $nsfw_boards), + 'alternate_spoilers' => in_array($board['uri'], $alunya_spoiler), + 'posting_enabled' => !in_array($board['uri'], $readonly_boards), + ]; +} + header('Content-Type: application/json'); echo json_encode([ 'captcha' => $config['securimage'], diff --git a/templates/header.html b/templates/header.html index 6c1e6346..d4ef94e0 100644 --- a/templates/header.html +++ b/templates/header.html @@ -17,7 +17,7 @@ {% if not nojavascript %} {% if not config.additional_javascript_compile %} - {% for javascript in config.additional_javascript %}{% endfor %} + {% for javascript in config.additional_javascript %}{% endfor %} {% endif %} {% endif %} {% if config.recaptcha %} diff --git a/templates/post/fileinfo.html b/templates/post/fileinfo.html index a551e8bb..6c5d06ae 100644 --- a/templates/post/fileinfo.html +++ b/templates/post/fileinfo.html @@ -22,9 +22,9 @@ {% if config.show_filename and file.filename %} , {% if file.filename|length > config.max_filename_display %} - {{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }} + {{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }} {% else %} - {{ file.filename|e|bidi_cleanup }} + {{ file.filename|e|bidi_cleanup }} {% endif %} {% endif %} ) @@ -36,3 +36,4 @@ {% endfor %} {% endif %} + diff --git a/templates/post_form.html b/templates/post_form.html index 1bcd1a72..f70871d4 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -1,4 +1,10 @@ -
+ {{ antibot.html() }} {% if id %}{% endif %} {{ antibot.html() }} @@ -142,8 +148,6 @@ - - {% if config.allow_upload_by_url %}
: diff --git a/templates/themes/categories/frames.html b/templates/themes/categories/frames.html index 7d02d584..400d3a3f 100644 --- a/templates/themes/categories/frames.html +++ b/templates/themes/categories/frames.html @@ -8,21 +8,38 @@ {{ settings.title }} + {% include 'themes/categories/' ~ settings.file_sidebar %} {% include 'themes/categories/' ~ settings.file_news %} + diff --git a/templates/themes/categories/news.html b/templates/themes/categories/news.html index a6683fd4..b9ffecca 100644 --- a/templates/themes/categories/news.html +++ b/templates/themes/categories/news.html @@ -1,13 +1,30 @@ {% filter remove_whitespace %} -
+
+ {{ boardlist.top }}

{{ settings.title }}

+
{{ settings.subtitle }}
+

{{ description }}

- +
+
{% if not news %}

{% trans %}(No news to show.){% endtrans %}

@@ -31,7 +48,7 @@ {% trans "Post Statistics" %}
- +
@@ -91,3 +108,4 @@ {% endfilter %} + diff --git a/templates/themes/categories/theme.php b/templates/themes/categories/theme.php index 44cae18f..a732a0e2 100644 --- a/templates/themes/categories/theme.php +++ b/templates/themes/categories/theme.php @@ -34,6 +34,9 @@ // Build homepage public static function homepage($settings) { global $config; + $description = 'Leftypol is a fun and enjoyable space where users can post anonymously.
' . + 'We engage in both serious political discourse and less serious informal discussions ' . + 'on various topics related to leftist thought.'; $query = query("SELECT * FROM ``news`` ORDER BY `time` DESC") or error(db_error()); $news = $query->fetchAll(PDO::FETCH_ASSOC); $stats = Categories::getPostStatistics($settings); @@ -42,6 +45,7 @@ Array( 'config' => $config, 'settings' => $settings, + 'description' => $description, 'categories' => Categories::getCategories($config), 'news' => $news, 'stats' => $stats, @@ -160,3 +164,4 @@ }; ?> +
{% trans "Board" %}