Browse Source

Merge branch 'config' of github.com:towards-a-new-leftypol/leftypol_lainchan into config

pull/40/head
Pietro Carrara 3 years ago
parent
commit
af967788dc
  1. 4
      inc/config.php
  2. 5
      inc/instance-config.php
  3. 3
      js/catalog-search.js
  4. 2
      js/download-original.js
  5. 2
      js/expand-all-images.js
  6. 2
      js/expand-video.js
  7. 41
      js/file-selector.js
  8. 2
      js/flag-preview.js
  9. 79
      js/image-hover.js
  10. 2
      js/inline-expanding-filename.js
  11. 2
      js/post-hover.js
  12. 2
      js/show-backlinks.js
  13. 2
      js/smartphone-spoiler.js
  14. 66
      js/style-select.js
  15. 2
      js/youtube.js
  16. 3
      post.php
  17. 46
      status.php
  18. 2
      templates/header.html
  19. 5
      templates/post/fileinfo.html
  20. 10
      templates/post_form.html
  21. 65
      templates/themes/categories/frames.html
  22. 24
      templates/themes/categories/news.html
  23. 5
      templates/themes/categories/theme.php

4
inc/config.php

@ -1921,3 +1921,7 @@
//Empty board alias
$config['boards_alias'] = array();
//Logo location for themes
$config['logo'] = 'static/logo.png';

5
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;

3
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);
}
}());

2
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')) {

2
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 id="expand-all-images" style="text-align:right"><a class="unimportant" href="javascript:void(0)"></a></div>');
$('div#expand-all-images a')
.text(_('Expand all images'))

2
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];

41
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', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
$('#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', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
$('#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));
});

2
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();

79
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",
"<fieldset><legend>Image hover</legend>"
@ -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 = $('<img id="chx_hoverImage" src="'+fullUrl+'" />');
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();
});
}

2
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');

2
js/post-hover.js

@ -13,7 +13,7 @@
*
*/
onready(function(){
$(document).ready(function () {
var dont_fetch_again = [];
init_hover = function() {
var $link = $(this);

2
js/show-backlinks.js

@ -13,7 +13,7 @@
*
*/
onready(function(){
$(document).ready(function(){
var showBackLinks = function() {
var reply_id = $(this).attr('id').replace(/^reply_/, '');

2
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');

66
js/style-select.js

@ -14,32 +14,42 @@
*
*/
onready(function(){
var stylesDiv = $('div.styles');
var pages = $('div.pages');
var stylesSelect = $('<select></select>');
var i = 1;
stylesDiv.children().each(function() {
var opt = $('<option></option>')
.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(
$('<div id="style-select"></div>')
/*.text(_('Style: '))*/
.append(stylesSelect)
);
});
$(document).ready(function() {
var stylesDiv = $('div.styles');
var pages = $('div.pages');
var stylesSelect = $('<select></select>').css({float:"none"});
var options = [];
var i = 1;
stylesDiv.children().each(function() {
var name = this.innerHTML.replace(/(^\[|\]$)/g, '');
var opt = $('<option></option>')
.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(
$('<div id="style-select"></div>')
.append(_('Select theme: '), stylesSelect)
);
});

2
js/youtube.js

@ -23,7 +23,7 @@
*/
onready(function(){
$(document).ready(function(){
const ON = "[Remove]";
const OFF = "[Embed]";

3
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));

46
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<string>: The board code ('b', 'tech', ...)
* - name<string>: The board user-readable name ('Siberia', ...)
* - description<string>: The board description ('Leftist Politically Incorrect', ...)
* - sfw<boolean>: Is this board sfw?
* - alternate_spoilers<boolean>: 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'],

2
templates/header.html

@ -17,7 +17,7 @@
{% if not nojavascript %}
<script type="text/javascript" src="{{ config.url_javascript }}"></script>
{% if not config.additional_javascript_compile %}
{% for javascript in config.additional_javascript %}<script type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %}
{% for javascript in config.additional_javascript %}<script defer type="text/javascript" src="{{ config.additional_javascript_url }}{{ javascript }}"></script>{% endfor %}
{% endif %}
{% endif %}
{% if config.recaptcha %}

5
templates/post/fileinfo.html

@ -22,9 +22,9 @@
{% if config.show_filename and file.filename %}
,
{% if file.filename|length > config.max_filename_display %}
<span class="postfilename" title="{{ file.filename|e|bidi_cleanup }}">{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }}</span>
<a href="{{ config.uri_img }}{{ file.file }}" download="{{ file.filename }}" title="Save as original filename">{{ file.filename|truncate_filename(config.max_filename_display)|e|bidi_cleanup }}</a>
{% else %}
<span class="postfilename">{{ file.filename|e|bidi_cleanup }}</span>
<a href="{{ config.uri_img }}{{ file.file }}" download="{{ file.filename }}" title="Save as original filename">{{ file.filename|e|bidi_cleanup }}</a>
{% endif %}
{% endif %}
)
@ -36,3 +36,4 @@
{% endfor %}
</div>
{% endif %}

10
templates/post_form.html

@ -1,4 +1,10 @@
<form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="{{ config.post_url }}" method="post">
<form
name="post" onsubmit="return dopost(this);"
enctype="multipart/form-data"
action="{{ config.post_url }}"
method="post"
data-max-images="{{ config.max_images }}"
>
{{ antibot.html() }}
{% if id %}<input type="hidden" name="thread" value="{{ id }}">{% endif %}
{{ antibot.html() }}
@ -142,8 +148,6 @@
<td>
<input type="file" name="file" id="upload_file">
<script type="text/javascript">if (typeof init_file_selector !== 'undefined') init_file_selector({{ config.max_images }});</script>
{% if config.allow_upload_by_url %}
<div style="float:none;text-align:left" id="upload_url">
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:

65
templates/themes/categories/frames.html

@ -8,21 +8,38 @@
<link rel="stylesheet" media="screen" href="/stylesheets/dark_red.css">
<style type="text/css">
.sidebar {
grid-column: 1;
grid-row: 1 / 3;
width: 200px;
border-right-color: gray;
border-right-style: solid;
border-width: 2px;
margin-right: 15px;
}
.introduction {
grid-column: 2 / 9;
grid-row: 1;
width: 100%;
}
.content {
grid-column: 2 / 9;
grid-row: 2;
width: 100%;
}
body {
display: flex;
display: grid;
grid-template-columns: repeat(auto-fill,minmax(200px, 1fr));
gap: 20px;
height: 100vh;
}
.modlog {
width: 50%;
text-align: left;
}
fieldset {
margin: 10px;
@ -54,13 +71,45 @@
}
@media (max-width:768px) {
body{
display: grid;
grid-template-columns: none;
gap: 20px;
height: 100vh;
width: 100%;
}
.introduction {
grid-column: 1;
grid-row: 1;
width: 100%;
}
.sidebar {
width: 80vw;
border: none;
grid-column: 1;
grid-row: 2;
width: 100%;
border-width: 2px;
}
.main {
flex-direction: column;
align-items: center;
.content {
grid-column: 1;
grid-row: 3;
width: 100%;
}
.modlog {
width: 100%;
text-align: center;
}
table {
table-layout: fixed;
}
table.modlog tr th {
white-space: normal;
word-wrap: break-word;
}
.boardlist {
@ -73,9 +122,11 @@
}
</style>
<title>{{ settings.title }}</title>
<meta name="description" content="{{ description }}">
</head>
<body>
{% include 'themes/categories/' ~ settings.file_sidebar %}
{% include 'themes/categories/' ~ settings.file_news %}
</body>
</html>

24
templates/themes/categories/news.html

@ -1,13 +1,30 @@
{% filter remove_whitespace %}
<div class="content">
<div class="introduction">
<style style="display:none;">
.home-logo {
display: block;
margin: auto;
min-width: 100px;
width: 15%;
}
.home-description {
margin: 20px auto 0 auto;
text-align: center;
max-width: 700px;"
}
</style>
{{ boardlist.top }}
<header>
<h1>{{ settings.title }}</h1>
<img src="{{ config.logo }}" alt="logo" class="home-logo">
<div class="subtitle">{{ settings.subtitle }}</div>
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}">
<link rel="stylesheet" media="screen" href="/stylesheets/dark_red.css">
<p class="home-description" >{{ description }}</p>
</header>
</div>
<div class="content">
<div class="ban">
{% if not news %}
<p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p>
@ -31,7 +48,7 @@
{% trans "Post Statistics" %}
</h1>
</div>
<table class="modlog" style="width: 50%; text-align: left;">
<table class="modlog">
<thead>
<tr>
<th>{% trans "Board" %}</th>
@ -91,3 +108,4 @@
</footer>
</div>
{% endfilter %}

5
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.<br>' .
'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 @@
};
?>

Loading…
Cancel
Save