##// END OF EJS Templates
Updated the Snow White theme. Scroll to the new post after posting to thread.
neko259 -
r41:68192446 default
parent child Browse files
Show More
@@ -1,163 +1,174 b''
1 1 * {
2 2 font-size: inherit;
3 3 margin: 0;
4 4 padding: 0;
5 5 }
6 6 html {
7 7 background: #fff;
8 8 color: #000;
9 9 font: medium sans-serif;
10 10 }
11 11 a {
12 12 color: inherit;
13 13 text-decoration: underline;
14 14 }
15 15
16 16 #admin_panel {
17 17 background: #182F6F;
18 18 color: #fff;
19 19 padding: .5ex 1ex .5ex 1ex;
20 20 }
21 21
22 22 #navigation_panel {
23 23 background: #182F6F;
24 24 color: #B4CFEC;
25 25 margin-bottom: 1em;
26 26 padding: .5ex 1ex 1ex 1ex;
27 27 }
28 28 #navigation_panel::after {
29 29 clear: both;
30 30 content: ".";
31 31 display: block;
32 32 height: 0;
33 33 line-height: 0;
34 34 visibility: hidden;
35 35 }
36 36
37 37 #navigation_panel a:link, #navigation_panel a:visited, #navigation_panel a:hover {
38 38 text-decoration: none;
39 39 }
40 40
41 41 #navigation_panel .link {
42 42 border-right: 1px solid #fff;
43 43 color: #fff;
44 44 font-weight: bold;
45 45 margin-right: 1ex;
46 46 padding-right: 1ex;
47 47 }
48 48 #navigation_panel .link:last-child {
49 49 border-left: 1px solid #fff;
50 50 border-right: none;
51 51 float: right;
52 52 margin-left: 1ex;
53 53 margin-right: 0;
54 54 padding-left: 1ex;
55 55 padding-right: 0;
56 56 }
57 57
58 58 #navigation_panel .tag {
59 59 color: #fff;
60 60 }
61 61
62 62 .title {
63 63 color: #182F6F;
64 64 font-weight: bold;
65 65 }
66 66
67 67 .post-form-w {
68 68 background: #182F6F;
69 69 border-radius: 1ex;
70 70 color: #fff;
71 71 margin: 1em 1ex;
72 72 padding: 1ex;
73 73 }
74 74 .post-form {
75 75 display: table;
76 76 border-collapse: collapse;
77 77 width: 100%;
78 78
79 79 }
80 80 .form-row {
81 81 display: table-row;
82 82 }
83 83 .form-label, .form-input {
84 84 display: table-cell;
85 85 vertical-align: top;
86 86 }
87 87 .form-label {
88 88 padding: .25em 1ex .25em 0;
89 89 }
90 90 .form-input {
91 91 padding: .25em 0;
92 92 }
93 93 .form-input > * {
94 94 background: #fff;
95 95 color: #000;
96 96 border: none;
97 97 padding: 0;
98 98 resize: vertical;
99 99 width: 100%;
100 100 }
101 101 .form-submit {
102 102 border-bottom: 1px solid #666;
103 103 margin-bottom: .5em;
104 104 padding-bottom: .5em;
105 105 }
106 106 .form-title {
107 107 font-weight: bold;
108 108 margin-bottom: .5em;
109 109 }
110 110 .post-form .settings_item {
111 111 margin: .5em 0;
112 112 }
113 113 .form-submit input {
114 114 margin-top: .5em;
115 115 padding: .2em 1ex;
116 116 }
117 117 .form-label {
118 118 text-align: right;
119 119 }
120 120
121 121 .block {
122 122 display: inline-block;
123 123 vertical-align: top;
124 124 }
125 125
126 126 .post_id {
127 127 color: #a00;
128 128 }
129 129
130 130 .post {
131 131 background: #FFF;
132 132 border-bottom: 1px solid #182F6F;
133 133 margin: 0 1ex 1em 1ex;
134 134 overflow-x: auto;
135 135 padding-bottom: 1em;
136 136 }
137 137
138 138 .metadata {
139 139 background: #C0E4E8;
140 140 border: 1px solid #7F9699;
141 141 border-radius: .4ex;
142 142 display: table;
143 143 margin-top: .5em;
144 144 padding: .4em;
145 145 }
146 146
147 147 .post ul, .post ol {
148 148 margin: .5em 0 .5em 3ex;
149 149 }
150 150 .post li {
151 151 margin: .2em 0;
152 152 }
153 153 .post p {
154 154 margin: .5em 0;
155 155 }
156 156 .post blockquote {
157 157 border-left: 3px solid #182F6F;
158 158 margin: .5em 0 .5em 3ex;
159 159 padding-left: 1ex;
160 160 }
161 161 .post blockquote > blockquote {
162 162 padding-top: .1em;
163 } No newline at end of file
163 }
164
165 .post > .image {
166 float: left;
167 margin-right: 1ex;
168 }
169 .post > .metadata {
170 clear: left;
171 }
172 .post {
173 clear: left;
174 }
@@ -1,164 +1,172 b''
1 from django.core.urlresolvers import reverse
1 2 from django.template import RequestContext
2 3 from boards import forms
3 4 import boards
4 5 from boards.forms import ThreadForm, PostForm, SettingsForm
5 6 from boards.models import Post, Admin, Tag
6 7 from django.shortcuts import render, get_list_or_404, redirect
7 8 from django.http import HttpResponseRedirect, Http404
8 9 import neboard
9 10
10 11
11 12 def index(request):
12 13 context = RequestContext(request)
13 14
14 15 if request.method == 'POST':
15 16 return new_post(request)
16 17 else:
17 18 threads = Post.objects.get_threads()
18 19
19 20 context['threads'] = None if len(threads) == 0 else threads
20 21 context['form'] = forms.ThreadForm()
21 22 context['tags'] = Tag.objects.get_not_empty_tags()
22 23 context['theme'] = _get_theme(request)
23 24
24 25 return render(request, 'posting_general.html',
25 26 context)
26 27
27 28
28 29 def new_post(request, thread_id=boards.models.NO_PARENT):
29 30 """Add a new post (in thread or as a reply)."""
30 31
31 32 if thread_id == boards.models.NO_PARENT:
32 33 form = ThreadForm(request.POST, request.FILES)
33 34 else:
34 35 form = PostForm(request.POST, request.FILES)
35 36
36 37 if form.is_valid():
37 38 data = form.cleaned_data
38 39 else:
39 40 return redirect(index)
40 41
41 42 title = data['title']
42 43 text = data['text']
43 44
44 45 if 'image' in data.keys():
45 46 image = data['image']
46 47 else:
47 48 image = None
48 49
49 50 ip = request.META['REMOTE_ADDR']
50 51
51 52 tags = []
52 if thread_id == boards.models.NO_PARENT:
53
54 new_thread = thread_id == boards.models.NO_PARENT
55 if new_thread:
53 56 tag_strings = data['tags']
54 57
55 58 if tag_strings:
56 59 tag_strings = tag_strings.split(' ')
57 60 for tag_name in tag_strings:
58 61 tag_name = tag_name.strip()
59 62 if len(tag_name) > 0:
60 63 tag, created = Tag.objects.get_or_create(name=tag_name)
61 64 tags.append(tag)
62 65
63 66 # TODO Add a possibility to define a link image instead of an image file.
64 67 # If a link is given, download the image automatically.
65 68
66 69 post = Post.objects.create_post(title=title, text=text, ip=ip,
67 70 parent_id=thread_id, image=image,
68 71 tags=tags)
69 72
70 thread_to_show = (post.id if thread_id == boards.models.NO_PARENT else
71 thread_id)
72 return redirect(thread, post_id=thread_to_show)
73 thread_to_show = (post.id if new_thread else thread_id)
74
75 if new_thread:
76 return redirect(thread, post_id=thread_to_show)
77 else:
78 return redirect(reverse(thread,
79 kwargs={'post_id': thread_to_show}) + '#'
80 + str(post.id))
73 81
74 82
75 83 def tag(request, tag_name):
76 84 """Get all tag threads (posts without a parent)."""
77 85
78 86 tag = Tag.objects.get(name=tag_name)
79 87 threads = Post.objects.get_threads(tag=tag)
80 88
81 89 if request.method == 'POST':
82 90 return new_post(request)
83 91 else:
84 92 context = RequestContext(request)
85 93 context['threads'] = None if len(threads) == 0 else threads
86 94 context['tag'] = tag_name
87 95 context['tags'] = Tag.objects.get_not_empty_tags()
88 96 context['theme'] = _get_theme(request)
89 97
90 98 context['form'] = forms.ThreadForm(initial={'tags': tag_name})
91 99
92 100 return render(request, 'posting_general.html',
93 101 context)
94 102
95 103
96 104 def thread(request, post_id):
97 105 """Get all thread posts"""
98 106
99 107 if request.method == 'POST':
100 108 return new_post(request, post_id)
101 109 else:
102 110 # TODO Show 404 if there is no such thread
103 111 posts = Post.objects.get_thread(post_id)
104 112
105 113 context = RequestContext(request)
106 114
107 115 context['posts'] = posts
108 116 context['form'] = forms.PostForm()
109 117 context['tags'] = Tag.objects.get_not_empty_tags()
110 118 context['theme'] = _get_theme(request)
111 119
112 120 return render(request, 'thread.html', context)
113 121
114 122
115 123 def login(request):
116 124 """Log in as admin"""
117 125
118 126 if 'name' in request.POST and 'password' in request.POST:
119 127 request.session['admin'] = False
120 128
121 129 isAdmin = len(Admin.objects.filter(name=request.POST['name'],
122 130 password=request.POST[
123 131 'password'])) > 0
124 132
125 133 if isAdmin:
126 134 request.session['admin'] = True
127 135
128 136 response = HttpResponseRedirect('/')
129 137
130 138 else:
131 139 response = render(request, 'login.html', {'error': 'Login error'})
132 140 else:
133 141 response = render(request, 'login.html', {})
134 142
135 143 return response
136 144
137 145
138 146 def logout(request):
139 147 request.session['admin'] = False
140 148 return HttpResponseRedirect('/')
141 149
142 150
143 151 def settings(request):
144 152 context = RequestContext(request)
145 153
146 154 if request.method == 'POST':
147 155 form = SettingsForm(request.POST)
148 156 if form.is_valid():
149 157 selected_theme = form.cleaned_data['theme']
150 158 request.session['theme'] = selected_theme
151 159
152 160 return redirect(settings)
153 161 else:
154 162 selected_theme = _get_theme(request)
155 163 form = SettingsForm(initial={'theme': selected_theme})
156 164 context['form'] = form
157 165 context['tags'] = Tag.objects.get_not_empty_tags()
158 166 context['theme'] = _get_theme(request)
159 167
160 168 return render(request, 'settings.html', context)
161 169
162 170
163 171 def _get_theme(request):
164 172 return request.session.get('theme', neboard.settings.DEFAULT_THEME) No newline at end of file
@@ -1,76 +1,76 b''
1 1 {% extends "base.html" %}
2 2
3 3 {% load i18n %}
4 4 {% load markup %}
5 5
6 6 {% block head %}
7 7 <title>Neboard</title>
8 8 {% endblock %}
9 9
10 10 {% block content %}
11 11
12 12 {% if posts %}
13 13 {% for post in posts %}
14 14 <a name="{{ post.id }}"></a>
15 15 <div class="post">
16 16 {% if post.image %}
17 <div class="block">
17 <div class="image">
18 18 <a href="{{ post.image.url }}"><img
19 19 src="{{ post.image.url_200x150 }}" />
20 20 </a>
21 21 </div>
22 22 {% endif %}
23 <div class="block">
23 <div class="message">
24 24 <span class="title">{{ post.title }}</span>
25 25 <a class="post_id" href="#{{ post.id }}">
26 26 (#{{ post.id }})</a>
27 27 [{{ post.pub_time }}]
28 28 {% autoescape off %}
29 29 {{ post.text.rendered }}
30 30 {% endautoescape %}
31 31 </div>
32 32 {% if post.tags.all %}
33 33 <div class="metadata">
34 34 <span class="tags">{% trans 'Tags' %}:
35 35 {% for tag in post.tags.all %}
36 36 <a class="tag" href="{% url 'tag' tag.name %}">
37 37 {{ tag.name }}</a>
38 38 {% endfor %}
39 39 </span>
40 40 </div>
41 41 {% endif %}
42 42 </div>
43 43 {% endfor %}
44 44 {% else %}
45 45 No threads found.
46 46 <hr />
47 47 {% endif %}
48 48
49 49 <form enctype="multipart/form-data" method="post">{% csrf_token %}
50 50 <div class="post-form-w">
51 51 <div class="form-title">{% trans "Reply to thread" %}</div>
52 52 <div class="post-form">
53 53 <div class="form-row">
54 54 <div class="form-label">{% trans 'Title' %}</div>
55 55 <div class="form-input">{{ form.title }}</div>
56 56 </div>
57 57 <div class="form-row">
58 58 <div class="form-label">{% trans 'Text' %}</div>
59 59 <div class="form-input">{{ form.text }}</div>
60 60 </div>
61 61 <div class="form-row">
62 62 <div class="form-label">{% trans 'Image' %}</div>
63 63 <div class="form-input">{{ form.image }}</div>
64 64 </div>
65 65 </div>
66 66 <div class="form-submit"><input type="submit"
67 67 value="{% trans "Post" %}"/></div>
68 68 <div>Use <a
69 69 href="http://daringfireball.net/projects/markdown/basics">
70 70 markdown</a> syntax for posting.</div>
71 71 <div>Example: *<i>italic</i>*, **<b>bold</b>**</div>
72 72 <div>Insert quotes with "&gt;"</div>
73 73 </div>
74 74 </form>
75 75
76 76 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now