From 505b4e18bd3c6953dc8d0b3f71bddd18265f44df Mon Sep 17 00:00:00 2001 From: TheAMM Date: Tue, 30 May 2017 18:56:09 +0300 Subject: [PATCH 1/5] Move to markdown-it, render markdown in DOMContentLoaded No more separate - + diff --git a/nyaa/templates/view.html b/nyaa/templates/view.html index b78594d..9c9595f 100644 --- a/nyaa/templates/view.html +++ b/nyaa/templates/view.html @@ -81,13 +81,13 @@
-
- {% if torrent.description %} +
+ {%- if torrent.description -%} {# Escape newlines into html entities because CF strips blank newlines #} - {{ torrent.description | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) }} - {% else %} + {{- torrent.description | escape | replace('\r\n', '\n') | replace('\n', ' '|safe) -}} + {%- else -%} #### No description. - {% endif%} + {%- endif -%}
@@ -161,19 +161,12 @@
{# Escape newlines into html entities because CF strips blank newlines #} -
{{ comment.text }}
+
{{ comment.text }}
- + {% endfor %} {% if comment_form %}
@@ -207,13 +200,4 @@ - - {% endblock %} \ No newline at end of file From f4fb9fc065802f019059dcdfed065e5f85b6e6c9 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Tue, 30 May 2017 19:20:00 +0300 Subject: [PATCH 2/5] Render markdown text field manually in the template We need to escape newlines in the editor as well! --- nyaa/templates/_formhelpers.html | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/nyaa/templates/_formhelpers.html b/nyaa/templates/_formhelpers.html index 212c753..d9e960a 100644 --- a/nyaa/templates/_formhelpers.html +++ b/nyaa/templates/_formhelpers.html @@ -50,7 +50,25 @@
- {{ render_field(field, False, class_='form-control markdown-source') }} + {# Render this field manually, because we need to escape the inner text #} + + {% if field.errors %} +
+ {% if field.errors|length < 2 %} + {% for error in field.errors %} + {{ error }} + {% endfor %} + {% else %} +
    + {% for error in field.errors %} +
  • {{ error }}
  • + {% endfor %} +
+ {% endif %} +
+ {% endif %}
From 80587e02fe7d675cf461044bb2df781daf713d0a Mon Sep 17 00:00:00 2001 From: TheAMM Date: Tue, 30 May 2017 19:35:28 +0300 Subject: [PATCH 3/5] Default description to "" in field renderer Otherwise we get None on upload page --- nyaa/templates/_formhelpers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/_formhelpers.html b/nyaa/templates/_formhelpers.html index d9e960a..d467735 100644 --- a/nyaa/templates/_formhelpers.html +++ b/nyaa/templates/_formhelpers.html @@ -52,7 +52,7 @@
{# Render this field manually, because we need to escape the inner text #} {% if field.errors %}
From ae30e9c95c999125c1c875c7650e5985eb608cb4 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 30 May 2017 21:05:15 +0200 Subject: [PATCH 4/5] Get started with a bare-bones help page It includes little anchors over headings that you can click to link your one reading-challenged friend to the right section. In the future, adding an explanation of the different categories and labels under a new h2 would be a good thing. --- nyaa/static/css/main.css | 16 +++++++++++ nyaa/templates/help.html | 59 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/nyaa/static/css/main.css b/nyaa/static/css/main.css index 4d70ea0..32e96a3 100644 --- a/nyaa/static/css/main.css +++ b/nyaa/static/css/main.css @@ -349,3 +349,19 @@ a.text-purple:hover, a.text-purple:active, a.text-purple:focus { color: #a760e0; .torrent-file-list .file-size { font-weight: bold; } + +.header-anchor { + padding-left: 0.5em; + visibility: hidden; + display: none; +} + +h1:hover .header-anchor, +h2:hover .header-anchor, +h3:hover .header-anchor, +h4:hover .header-anchor, +h5:hover .header-anchor, +h6:hover .header-anchor { + visibility: visible; + display: inline-block; +} diff --git a/nyaa/templates/help.html b/nyaa/templates/help.html index c8b4b81..64582fb 100644 --- a/nyaa/templates/help.html +++ b/nyaa/templates/help.html @@ -2,7 +2,64 @@ {% block title %}Help :: {{ config.SITE_NAME }}{% endblock %} {% block body %} -

Coming soon (tm)

+{% macro linkable_header(heading, label) %} +

{{ heading }}

+{% endmacro %} + +

Help

+ +

Using the Site

+ +{{ linkable_header("How to Download", "how-to-dl") }} +

+ This site only offers torrent files and magnet links. To download the content of + the torrents, you will have to use a BitTorrent client such as qBitTorrent, + µTorrent, Transmission or Deluge. +

+ +{{ linkable_header("Using the Search Function", "using-search") }} +

+ You can combine search terms with the | operator, such as + horrible|cartel. +

+

+ To exclude results matching a certain word, prefix them with -, + e.g. FFF -memesubs, which will return torrents with FFF in the + name, but not those which have memesubs in the name as well. +

+

+ If you want to search for a several-word expression in its entirety, you can + surround searches with " (double quotes), such as + "foo bar", which would match torrents named foo bar but not + those named bar foo. +

+ +{{ linkable_header("Reporting Torrents", "reporting") }} +

+ If you find a torrent that breaks the rules, click the + button to the right + of the torrent's information page. Then, enter a reason for your report in the + dialog that opens, and hit the button to confirm. +

+ +{{ linkable_header("Styling Descriptions and Comments", "styling") }} +

+ You can style your comments and your torrent's description using + Markdown + . This includes adding images or linking to external websites. +

+

+ To link to an external site, use [label of link](https://example.com) + where the text in the [] square brackets is the shown text of your + link, and the URL in the () parentheses is the URL your link will + point to. +

+

+ Embedding an image is similar. Use ![alt text](https://example.com/image.jpg) + to have an image embedded in your comment or description. Note the ! + exclamation mark at the beginning, denoting that this link is an image. +

{#

Help

The search engine is located at the top right, and it allows users to search through the torrent titles available on the site. Results matching either word A or B can be included by typing a vertical bar between them (|). Results matching a certain word can be excluded by prefixing that word with a hyphen-minus (-). Phrases can be matched by surrounding them with double-quotes (). Search results can be filtered by category, remake, trusted, and/or A+ status, and then narrowed down further by age and size ranges as well as excluding specific users. Sorting can be done in ascending or descending order by date, amount of seeders/leechers/downloads, size, or name. The search engine adapts to the current view and makes it possible to search for specific torrents in a specific subcategory from a specific user.

From e564b3ee19ad7e894387c85868243451fec710fc Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Tue, 30 May 2017 19:14:56 +0200 Subject: [PATCH 5/5] Change label of button on edit page Small nitpick change. "Edit" being the button that saves the edits might be a little confusing, whereas "Save Changes" is less ambiguous and more easily recognised. --- nyaa/templates/edit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nyaa/templates/edit.html b/nyaa/templates/edit.html index 07fc734..afc3df1 100644 --- a/nyaa/templates/edit.html +++ b/nyaa/templates/edit.html @@ -89,7 +89,7 @@
- +