From 22e403e0ffff6ecd34522985636cd666e1727e6e Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 3 May 2020 00:43:13 +0200 Subject: [PATCH] added basic markdown doc --- cookbook/forms.py | 4 + cookbook/templates/markdown_info.html | 214 ++++++++++++++++++++++++++ cookbook/urls.py | 2 + cookbook/views/views.py | 4 + 4 files changed, 224 insertions(+) create mode 100644 cookbook/templates/markdown_info.html diff --git a/cookbook/forms.py b/cookbook/forms.py index 422b89d8b..c283857e8 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -1,5 +1,6 @@ from django import forms from django.forms import widgets +from django.urls import reverse, reverse_lazy from django.utils.translation import gettext as _ from emoji_picker.widgets import EmojiPickerTextInput @@ -85,6 +86,9 @@ class InternalRecipeForm(forms.ModelForm): 'waiting_time': _('Waiting time (cooking/baking) in minutes'), } widgets = {'keywords': MultiSelectWidget} + help_texts = { + 'instructions': _('You can use markdown to format the instructions. See the docs here') + } class ShoppingForm(forms.Form): diff --git a/cookbook/templates/markdown_info.html b/cookbook/templates/markdown_info.html new file mode 100644 index 000000000..8bef1e9d6 --- /dev/null +++ b/cookbook/templates/markdown_info.html @@ -0,0 +1,214 @@ +{% extends "base.html" %} +{% load static %} +{% load i18n %} + +{% block title %}{% trans "Markdown Info" %}{% endblock %} + +{% block extra_head %} + +{% endblock %} + +{% block content %} + +

{% trans 'Markdown Info' %}

+ {% blocktrans %} + Markdown is lightweight markup language that can be used to format plain text easily. + This site uses the Python Markdown library to + convert your text into nice looking html. Its full markdown documentation can be found + here. + An incomplete but most likely sufficient documentation can be found below. + {% endblocktrans %} + +
+
+ +

{% trans 'Headers' %}

+

+    # Header 1
+    ## Header 2
+    ### Header 3
+    #### Header 4
+    ##### Header 5
+    ###### Header 6
+    
+ +
+ +
+
+
+ +
+
+

Header 1

+

Header 2

+

Header 3

+

Header 4

+
Header 5
+
Header 6
+
+ +
+ +
+

{% trans 'Formatting' %}

+

+        {% trans 'Line breaks are inserted by adding two spaces after the end of a line' %}
+        {% trans 'or by leaving a blank line inbetween.' %}
+
+        **{% trans 'This text is bold' %}**
+        *{% trans 'This text is in italics' %}*
+        > {% trans 'Blockquotes are also possible' %}
+    
+ +
+ +
+
+
+ +
+
+ {% trans 'Line breaks are inserted by adding two spaces after the end of a line' %}
+ {% trans 'or by leaving a blank line inbetween.' %}

+ {% trans 'This text is bold' %}
+ {% trans 'This text is in italics' %} +
+

{% trans 'Blockquotes are also possible' %}

+
+
+ +
+ +
+

{% trans 'Lists' %}

+ {% trans 'Lists can ordered or unorderd. It is important to leave a blank line before the list!' %} +

+        {% trans 'Ordered List' %}
+
+        - {% trans 'unordered list item' %}
+        - {% trans 'unordered list item' %}
+        - {% trans 'unordered list item' %}
+
+        {% trans 'Unordered List' %}
+
+        1. {% trans 'ordered list item' %}
+        2. {% trans 'ordered list item' %}
+        3. {% trans 'ordered list item' %}
+    
+ +
+ +
+
+
+ +
+
+ {% trans 'Ordered List' %} +
    +
  • {% trans 'unordered list item' %}
  • +
  • {% trans 'unordered list item' %}
  • +
  • {% trans 'unordered list item' %}
  • +
+ {% trans 'Unordered List' %} +
    +
  1. {% trans 'ordered list item' %}
  2. +
  3. {% trans 'ordered list item' %}
  4. +
  5. {% trans 'ordered list item' %}
  6. +
+
+ +
+ +
+

{% trans 'Images & Links' %}

+ {% trans 'Links can be formatted with Markdown. This applicaiton also allows to paste links directly into markdown fields without any formatting.' %} +

+        https://github.com/vabene1111/recipes
+        [](https://github.com/vabene1111/recipes)
+        [GitHub](https://github.com/vabene1111/recipes)
+
+        ![{% trans 'This will become and Image' %}]({% static 'favicon.png' %})
+    
+ +
+ +
+
+
+ +
+ + +
+ +
+

{% trans 'Tables' %}

+ {% trans 'Markdown tables are hard to create by hand. It is recommended to use a table editor like this one.' %} +

+        |  {% trans 'Table' %} | {% trans 'Header' %}  |
+        |--------|---------|
+        | {% trans 'Table' %}  | {% trans 'Cell' %}    |
+    
+ +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + +
{% trans 'Table' %}{% trans 'Header' %}
{% trans 'Table' %}{% trans 'Cell' %}
+
+ +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/cookbook/urls.py b/cookbook/urls.py index 1d0f9c48c..eade70319 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -45,6 +45,8 @@ urlpatterns = [ path('dal/keyword/', dal.KeywordAutocomplete.as_view(), name='dal_keyword'), path('dal/ingredient/', dal.IngredientsAutocomplete.as_view(), name='dal_ingredient'), path('dal/unit/', dal.UnitAutocomplete.as_view(), name='dal_unit'), + + path('docs/markdown/', views.markdown_info, name='docs_markdown'), ] generic_models = (Recipe, RecipeImport, Storage, RecipeBook, MealPlan, SyncLog, Sync, Comment, RecipeBookEntry, Keyword, Ingredient) diff --git a/cookbook/views/views.py b/cookbook/views/views.py index 3921a1a58..a31f9e2bf 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -216,3 +216,7 @@ def settings(request): preference_form = UserPreferenceForm() return render(request, 'settings.html', {'preference_form': preference_form, 'user_name_form': user_name_form, 'password_form': password_form}) + + +def markdown_info(request): + return render(request, 'markdown_info.html', {})