aboutsummaryrefslogtreecommitdiff
path: root/templates/macros.twig
blob: 4e1b336ec64a4b5af6880dfcd7df1883d8d8b3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{% macro taglink(tag) %}
    <a href="{{ url("search") ~ "?q=" ~ ("#" ~ (tag|search_escape))|e("url") }}">{{ tag }}</a>
{% endmacro %}

{% macro tagcloud(tagcloud) %}
    <ul class="tagcloud">{% for tag, magnitude in tagcloud %}
        <li class="tag tc-{{ magnitude }}">{{ _self.taglink(tag) }}</li>
    {%  endfor %}</ul>
{% endmacro %}

{% macro searchbox(query="") %}
    <form action="{{ url("search") }}" class="search-form">
        <input
                type="text"
                name="q"
                placeholder="foo bar, #tag1 #tag2, &quot;full text&quot; and (#tag1 or #tag2), ..."
                value="{{ query }}"
                class="search-input"
        />
        <button type="submit" class="search-btn">Search</button>
    </form>
{% endmacro %}

{% macro note_form_content(note) %}
    <div class="labelled">
        <label for="note-content">Content</label>
        <div class="labelled-content">
            <textarea id="note-content" name="content">{{ note.content }}</textarea>
        </div>
    </div>
    <fieldset class="tags">
        <legend>Tags</legend>
        {% for tag in note.tags %}
            <input type="text" name="tag[]" value="{{ tag }}" />
        {% endfor %}
        {% for i in 0..10 %}
            <input type="text" name="tag[]" />
        {% endfor %}
    </fieldset>
    <div class="attachments-container">
        <h2>Attachments</h2>
        <ul class="attachment-list">
            {% for att in note.attachments %}
                <li>
                    <a href="{{ url("attachments/%s", att.id) }}">{{ att.fileName ? att.fileName : att.id }}</a>
                </li>
            {% endfor %}
        </ul>

        <ul class="attachment-inputs">
            <li><input type="file" name="attachments[]"></li>
        </ul>
    </div>
{% endmacro %}

{% macro new_note() %}
    <section class="new-note">
        <h2>New Note</h2>
        <form action="{{ url("new-note") }}" method="post" enctype="multipart/form-data">
            {{ _self.note_form_content({}) }}
            <button type="submit">Create</button>
        </form>
    </section>
{% endmacro %}