##// END OF EJS Templates
Templates moved to fit django documentation structure....
Ilyas -
r84:842448d8 default
parent child Browse files
Show More
1 NO CONTENT: file renamed from boards/templates/base.html to boards/templates/boards/base.html
1 NO CONTENT: file renamed from boards/templates/login.html to boards/templates/boards/login.html
@@ -1,164 +1,164 b''
1 {% extends "base.html" %}
1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5
6 6 {% block head %}
7 7 {% if tag %}
8 8 <title>Neboard - {{ tag }}</title>
9 9 {% else %}
10 10 <title>Neboard</title>
11 11 {% endif %}
12 12 {% endblock %}
13 13
14 14 {% block content %}
15 15
16 16 {% if tag %}
17 17 <div class="tag_info">
18 18 <h2>{% trans 'Tag: ' %}{{ tag }}</h2>
19 19 </div>
20 20 {% endif %}
21 21
22 22 {% if threads %}
23 23 {% for thread in threads %}
24 24 <div class="thread">
25 25 {% if thread.can_bump %}
26 26 <div class="post">
27 27 {% else %}
28 28 <div class="post dead_post">
29 29 {% endif %}
30 30 {% if thread.image %}
31 31 <div class="image">
32 32 <a class="fancy"
33 33 href="{{ thread.image.url }}"><img
34 34 src="{{ thread.image.url_200x150 }}"
35 35 alt="{% trans 'Post image' %}" />
36 36 </a>
37 37 </div>
38 38 {% endif %}
39 39 <div class="message">
40 40 <div class="post-info">
41 41 <span class="title">{{ thread.title }}</span>
42 42 <a class="post_id" href="{% url 'thread' thread.id %}">
43 43 (#{{ thread.id }})</a>
44 44 [{{ thread.pub_time }}]
45 45 [<a class="link" href="{% url 'thread' thread.id %}#form"
46 46 >{% trans "Reply" %}</a>]
47 47 </div>
48 48 {% autoescape off %}
49 49 {{ thread.text.rendered|truncatewords_html:50 }}
50 50 {% endautoescape %}
51 51 </div>
52 52 <div class="metadata">
53 53 {{ thread.get_reply_count }} {% trans 'replies' %},
54 54 {{ thread.get_images_count }} {% trans 'images' %}.
55 55 {% if thread.tags.all %}
56 56 <span class="tags">{% trans 'Tags' %}:
57 57 {% for tag in thread.tags.all %}
58 58 <a class="tag" href="
59 59 {% url 'tag' tag_name=tag.name %}">
60 60 {{ tag.name }}</a>
61 61 {% endfor %}
62 62 </span>
63 63 {% endif %}
64 64 </div>
65 65 </div>
66 66 {% if thread.get_last_replies %}
67 67 <div class="last-replies">
68 68 {% for post in thread.get_last_replies %}
69 69 {% if thread.can_bump %}
70 70 <div class="post">
71 71 {% else %}
72 72 <div class="post dead_post">
73 73 {% endif %}
74 74 {% if post.image %}
75 75 <div class="image">
76 76 <a class="fancy"
77 77 href="{{ post.image.url }}"><img
78 78 src=" {{ post.image.url_200x150 }}"
79 79 alt="{% trans 'Post image' %}" />
80 80 </a>
81 81 </div>
82 82 {% endif %}
83 83 <div class="message">
84 84 <div class="post-info">
85 85 <span class="title">{{ post.title }}</span>
86 86 <a class="post_id" href="
87 87 {% url 'thread' thread.id %}#{{ post.id }}">
88 88 (#{{ post.id }})</a>
89 89 [{{ post.pub_time }}]
90 90 </div>
91 91 {% autoescape off %}
92 92 {{ post.text.rendered|truncatewords_html:50 }}
93 93 {% endautoescape %}
94 94 </div>
95 95 </div>
96 96 {% endfor %}
97 97 </div>
98 98 {% endif %}
99 99 </div>
100 100 {% endfor %}
101 101 {% else %}
102 102 No threads found.
103 103 <hr />
104 104 {% endif %}
105 105
106 106 <form enctype="multipart/form-data" method="post">{% csrf_token %}
107 107 <div class="post-form-w">
108 108
109 109 <div class="form-title">{% trans "Create new thread" %}</div>
110 110 <div class="post-form">
111 111 <div class="form-row">
112 112 <div class="form-label">{% trans 'Title' %}</div>
113 113 <div class="form-input">{{ form.title }}</div>
114 114 <div class="form-errors">{{ form.title.errors }}</div>
115 115 </div>
116 116 <div class="form-row">
117 117 <div class="form-label">{% trans 'Text' %}</div>
118 118 <div class="form-input">{{ form.text }}</div>
119 119 <div class="form-errors">{{ form.text.errors }}</div>
120 120 </div>
121 121 <div class="form-row">
122 122 <div class="form-label">{% trans 'Image' %}</div>
123 123 <div class="form-input">{{ form.image }}</div>
124 124 <div class="form-errors">{{ form.image.errors }}</div>
125 125 </div>
126 126 <div class="form-row">
127 127 <div class="form-label">{% trans 'Tags' %}</div>
128 128 <div class="form-input">{{ form.tags }}</div>
129 129 <div class="form-errors">{{ form.tags.errors }}</div>
130 130 </div>
131 131 <div class="form-row">
132 132 {{ form.captcha }}
133 133 </div>
134 134 </div>
135 135 <div class="form-submit">
136 136 <input type="submit" value="{% trans "Post" %}"/></div>
137 137 <div>Tags must be delimited by spaces. Text or image is required
138 138 </div>
139 139 <div>Use <a
140 140 href="http://daringfireball.net/projects/markdown/basics">
141 141 markdown</a> syntax for posting.</div>
142 142 </div>
143 143 </form>
144 144
145 145 {% endblock %}
146 146
147 147 {% block metapanel %}
148 148
149 149 <span class="metapanel">
150 150 <b><a href="https://bitbucket.org/neko259/neboard/">Neboard</a>
151 151 2013-05 (dev)</b>
152 152 {% trans "Pages:" %}
153 153 {% for page in pages %}
154 154 [<a href="
155 155 {% if tag %}
156 156 {% url "tag" tag_name=tag page=page %}
157 157 {% else %}
158 158 {% url "index" page=page %}
159 159 {% endif %}
160 160 ">{{ page }}</a>]
161 161 {% endfor %}
162 162 </span>
163 163
164 164 {% endblock %}
@@ -1,34 +1,34 b''
1 {% extends "base.html" %}
1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4
5 5 {% block head %}
6 6 <title>Neboard settings</title>
7 7 {% endblock %}
8 8
9 9 {% block content %}
10 10
11 11 <div class="post-form-w">
12 12 <div class="post-form">
13 13 <span class="form-title">{% trans "Theme" %}</span>
14 14 <form method="post">{% csrf_token %}
15 15 {% for choice in form.fields.theme.choices %}
16 16 <div class="settings_item">
17 17 <label for="{{ choice.0 }}">
18 18 <input type="radio" name="theme"
19 19 id="{{ choice.0 }}"
20 20 value="{{ choice.0 }}"
21 21 {% ifequal form.initial.theme choice.0 %}
22 22 checked
23 23 {% endifequal %}
24 24 />
25 25 {{ choice.1 }}
26 26 </label>
27 27 </div>
28 28 {% endfor %}
29 29 <input type="submit" value="{% trans "Save" %}" />
30 30 </form>
31 31 </div>
32 32 </div>
33 33
34 34 {% endblock %} No newline at end of file
@@ -1,24 +1,24 b''
1 {% extends "base.html" %}
1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5
6 6 {% block head %}
7 7 <title>Neboard - {% trans "tags" %}</title>
8 8 {% endblock %}
9 9
10 10 {% block content %}
11 11
12 12 <div class="post">
13 13 {% if tags %}
14 14 {% for tag in all_tags %}
15 15 <a class="tag" href="{% url 'tag' tag.name %}">
16 16 {{ tag.name }}</a><br />
17 17 {% endfor %}
18 18 {% else %}
19 19 No tags found.
20 20 <hr />
21 21 {% endif %}
22 22 </div>
23 23
24 24 {% endblock %} No newline at end of file
@@ -1,112 +1,112 b''
1 {% extends "base.html" %}
1 {% extends "boards/base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5
6 6 {% block head %}
7 7 <title>Neboard - {{ posts.0.title }}</title>
8 8 {% endblock %}
9 9
10 10 {% block content %}
11 11 <script src="{{ STATIC_URL }}js/thread.js"></script>
12 12
13 13 {% if posts %}
14 14 <div id="posts">
15 15 {% for post in posts %}
16 16 {% if posts.0.can_bump %}
17 17 <div class="post" id="{{ post.id }}">
18 18 {% else %}
19 19 <div class="post dead_post" id="{{ post.id }}">
20 20 {% endif %}
21 21 {% if post.image %}
22 22 <div class="image">
23 23 <a
24 24 class="fancy"
25 25 href="{{ post.image.url }}"><img
26 26 src="{{ post.image.url_200x150 }}"
27 27 alt="{% trans 'Post image' %}" />
28 28 </a>
29 29 </div>
30 30 {% endif %}
31 31 <div class="message">
32 32 <div class="post-info">
33 33 <span class="title">{{ post.title }}</span>
34 34 <a class="post_id" href="#{{ post.id }}">
35 35 (#{{ post.id }})</a>
36 36 [{{ post.pub_time }}]
37 37 {% if post.is_get %}
38 38 <span class="get">
39 39 {% trans "Get!" %}
40 40 </span>
41 41 {% endif %}
42 42 </div>
43 43 {% autoescape off %}
44 44 {{ post.text.rendered }}
45 45 {% endautoescape %}
46 46 </div>
47 47 {% if post.tags.all %}
48 48 <div class="metadata">
49 49 <span class="tags">{% trans 'Tags' %}:
50 50 {% for tag in post.tags.all %}
51 51 <a class="tag" href="{% url 'tag' tag.name %}">
52 52 {{ tag.name }}</a>
53 53 {% endfor %}
54 54 </span>
55 55 </div>
56 56 {% endif %}
57 57 </div>
58 58 {% endfor %}
59 59 </div>
60 60 {% else %}
61 61 No thread found.
62 62 <hr />
63 63 {% endif %}
64 64
65 65 <form id="form" enctype="multipart/form-data" method="post"
66 66 >{% csrf_token %}
67 67 <div class="post-form-w">
68 68 <div class="form-title">{% trans "Reply to thread" %}</div>
69 69 <div class="post-form">
70 70 <div class="form-row">
71 71 <div class="form-label">{% trans 'Title' %}</div>
72 72 <div class="form-input">{{ form.title }}</div>
73 73 <div class="form-errors">{{ form.title.errors }}</div>
74 74 </div>
75 75 <div class="form-row">
76 76 <div class="form-label">{% trans 'Text' %}</div>
77 77 <div class="form-input">{{ form.text }}</div>
78 78 <div class="form-errors">{{ form.text.errors }}</div>
79 79 </div>
80 80 <div class="form-row">
81 81 <div class="form-label">{% trans 'Image' %}</div>
82 82 <div class="form-input">{{ form.image }}</div>
83 83 <div class="form-errors">{{ form.image.errors }}</div>
84 84 </div>
85 85 <div class="form-row">
86 86 {{ form.captcha }}
87 87 </div>
88 88 </div>
89 89
90 90 <div class="form-submit"><input type="submit"
91 91 value="{% trans "Post" %}"/></div>
92 92 <div><a href="http://daringfireball.net/projects/markdown/basics">
93 93 {% trans 'Basic markdown syntax.' %}</a></div>
94 94 <div>{% trans 'Example: ' %}*<i>{% trans 'italic' %}</i>*,
95 95 **<b>{% trans 'bold' %}</b>**</div>
96 96 <div>{% trans 'Quotes can be inserted with' %} "&gt;"</div>
97 97 <div>{% trans 'Links to answers can be inserted with' %} "&gt;&gt;
98 98 123"</div>
99 99 </div>
100 100 </form>
101 101
102 102 {% endblock %}
103 103
104 104 {% block metapanel %}
105 105
106 106 <span class="metapanel">
107 107 {{ posts.0.get_reply_count }} {% trans 'replies' %},
108 108 {{ posts.0.get_images_count }} {% trans 'images' %}.
109 109 {% trans 'Last update: ' %}{{ posts.0.last_edit_time }}
110 110 </span>
111 111
112 112 {% endblock %} No newline at end of file
@@ -1,212 +1,212 b''
1 1 from django.core.urlresolvers import reverse
2 2 from django.template import RequestContext
3 3 from django.shortcuts import render, redirect, get_object_or_404
4 4 from django.http import HttpResponseRedirect
5 5
6 6 from boards import forms
7 7 import boards
8 8 from boards import utils
9 9 from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \
10 10 ThreadCaptchaForm, PostCaptchaForm
11 11
12 12 from boards.models import Post, Admin, Tag
13 13 import neboard
14 14
15 15
16 16 def index(request, page=0):
17 17 context = RequestContext(request)
18 18
19 19 threadFormClass = (ThreadForm
20 20 if utils.check_if_human(request)
21 21 else ThreadCaptchaForm)
22 22
23 23 if request.method == 'POST':
24 24 form = threadFormClass(request.POST, request.FILES,
25 25 error_class=PlainErrorList)
26 26
27 27 if form.is_valid():
28 28 return _new_post(request, form)
29 29 else:
30 30 form = threadFormClass(error_class=PlainErrorList)
31 31
32 32 threads = Post.objects.get_threads(page=int(page))
33 33
34 34 # TODO Get rid of the duplicate code in index and tag views
35 35 context['threads'] = None if len(threads) == 0 else threads
36 36 context['form'] = form
37 37 context['tags'] = Tag.objects.get_popular_tags()
38 38 context['theme'] = _get_theme(request)
39 39 context['pages'] = range(Post.objects.get_thread_page_count())
40 40
41 return render(request, 'posting_general.html',
41 return render(request, 'boards/posting_general.html',
42 42 context)
43 43
44 44
45 45 def _new_post(request, form, thread_id=boards.models.NO_PARENT):
46 46 """Add a new post (in thread or as a reply)."""
47 47
48 48 data = form.cleaned_data
49 49
50 50 title = data['title']
51 51 text = data['text']
52 52
53 53 if 'image' in data.keys():
54 54 image = data['image']
55 55 else:
56 56 image = None
57 57
58 58 ip = _get_client_ip(request)
59 59
60 60 tags = []
61 61
62 62 new_thread = thread_id == boards.models.NO_PARENT
63 63 if new_thread:
64 64 tag_strings = data['tags']
65 65
66 66 if tag_strings:
67 67 tag_strings = tag_strings.split(' ')
68 68 for tag_name in tag_strings:
69 69 tag_name = tag_name.strip()
70 70 if len(tag_name) > 0:
71 71 tag, created = Tag.objects.get_or_create(name=tag_name)
72 72 tags.append(tag)
73 73
74 74 # TODO Add a possibility to define a link image instead of an image file.
75 75 # If a link is given, download the image automatically.
76 76
77 77 post = Post.objects.create_post(title=title, text=text, ip=ip,
78 78 parent_id=thread_id, image=image,
79 79 tags=tags)
80 80
81 81 thread_to_show = (post.id if new_thread else thread_id)
82 82
83 83 if new_thread:
84 84 return redirect(thread, post_id=thread_to_show)
85 85 else:
86 86 return redirect(reverse(thread,
87 87 kwargs={'post_id': thread_to_show}) + '#'
88 88 + str(post.id))
89 89
90 90
91 91 def tag(request, tag_name, page=0):
92 92 """Get all tag threads (posts without a parent)."""
93 93
94 94 tag = get_object_or_404(Tag, name=tag_name)
95 95 threads = Post.objects.get_threads(tag=tag, page=int(page))
96 96
97 97 if request.method == 'POST':
98 98 form = ThreadForm(request.POST, request.FILES,
99 99 error_class=PlainErrorList)
100 100 if form.is_valid():
101 101 return _new_post(request, form)
102 102 else:
103 103 form = forms.ThreadForm(initial={'tags': tag_name},
104 104 error_class=PlainErrorList)
105 105
106 106 context = RequestContext(request)
107 107 context['threads'] = None if len(threads) == 0 else threads
108 108 context['tag'] = tag_name
109 109 context['tags'] = Tag.objects.get_popular_tags()
110 110 context['theme'] = _get_theme(request)
111 111 context['pages'] = range(Post.objects.get_thread_page_count(tag=tag))
112 112
113 113 context['form'] = form
114 114
115 return render(request, 'posting_general.html',
115 return render(request, 'boards/posting_general.html',
116 116 context)
117 117
118 118
119 119 def thread(request, post_id):
120 120 """Get all thread posts"""
121 121
122 122 postFormClass = (PostForm if utils.check_if_human(request) else
123 123 PostCaptchaForm)
124 124
125 125 if request.method == 'POST':
126 126 form = postFormClass(request.POST, request.FILES,
127 127 error_class=PlainErrorList)
128 128 if form.is_valid():
129 129 return _new_post(request, form, post_id)
130 130 else:
131 131 form = postFormClass(error_class=PlainErrorList)
132 132
133 133 posts = Post.objects.get_thread(post_id)
134 134
135 135 context = RequestContext(request)
136 136
137 137 context['posts'] = posts
138 138 context['form'] = form
139 139 context['tags'] = Tag.objects.get_popular_tags()
140 140 context['theme'] = _get_theme(request)
141 141
142 return render(request, 'thread.html', context)
142 return render(request, 'boards/thread.html', context)
143 143
144 144
145 145 def login(request):
146 146 """Log in as admin"""
147 147
148 148 if 'name' in request.POST and 'password' in request.POST:
149 149 request.session['admin'] = False
150 150
151 151 isAdmin = len(Admin.objects.filter(name=request.POST['name'],
152 152 password=request.POST[
153 153 'password'])) > 0
154 154
155 155 if isAdmin:
156 156 request.session['admin'] = True
157 157
158 158 response = HttpResponseRedirect('/')
159 159
160 160 else:
161 response = render(request, 'login.html', {'error': 'Login error'})
161 response = render(request, 'boards/login.html', {'error': 'Login error'})
162 162 else:
163 response = render(request, 'login.html', {})
163 response = render(request, 'boards/login.html', {})
164 164
165 165 return response
166 166
167 167
168 168 def logout(request):
169 169 request.session['admin'] = False
170 170 return HttpResponseRedirect('/')
171 171
172 172
173 173 def settings(request):
174 174 context = RequestContext(request)
175 175
176 176 if request.method == 'POST':
177 177 form = SettingsForm(request.POST)
178 178 if form.is_valid():
179 179 selected_theme = form.cleaned_data['theme']
180 180 request.session['theme'] = selected_theme
181 181
182 182 return redirect(settings)
183 183 else:
184 184 selected_theme = _get_theme(request)
185 185 form = SettingsForm(initial={'theme': selected_theme})
186 186 context['form'] = form
187 187 context['tags'] = Tag.objects.get_popular_tags()
188 188 context['theme'] = _get_theme(request)
189 189
190 return render(request, 'settings.html', context)
190 return render(request, 'boards/settings.html', context)
191 191
192 192
193 193 def all_tags(request):
194 194 context = RequestContext(request)
195 195 context['tags'] = Tag.objects.get_popular_tags()
196 196 context['theme'] = _get_theme(request)
197 197 context['all_tags'] = Tag.objects.get_not_empty_tags()
198 198
199 return render(request, 'tags.html', context)
199 return render(request, 'boards/tags.html', context)
200 200
201 201
202 202 def _get_theme(request):
203 203 return request.session.get('theme', neboard.settings.DEFAULT_THEME)
204 204
205 205
206 206 def _get_client_ip(request):
207 207 x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
208 208 if x_forwarded_for:
209 209 ip = x_forwarded_for.split(',')[-1].strip()
210 210 else:
211 211 ip = request.META.get('REMOTE_ADDR')
212 212 return ip
General Comments 0
You need to be logged in to leave comments. Login now