aboutsummaryrefslogtreecommitdiff
path: root/templates/macros.twig
blob: 2bc163adb5b45c12107a60f5f133ef351e899296 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{% 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>
        <table class="attachments">
            <thead>
                <tr>
                    <th>Delete</th>
                    <th>File name</th>
                </tr>
            </thead>
            <tbody>
                {% for att in note.attachments %}
                    <tr class="existing">
                        <td>
                            <input type="checkbox" class="attachment-delete-checkbox" value="1" name="attachment_delete[{{ att.id }}]">
                        </td>
                        <td>
                            <a href="{{ url("attachments/%s", att.id) }}">{{ att.fileName ? att.fileName : att.id }}</a>
                        </td>
                    </tr>
                {% endfor %}
                <tr class="new">
                    <td></td>
                    <td>
                        <input type="file" multiple name="attachments[]">
                    </td>
                </tr>
            </tbody>
        </table>
    </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>
            <button type="submit" name="create_and_new" value="1">Create & New</button>
        </form>
    </section>
{% endmacro %}