Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
d7135e4d
Commit
d7135e4d
authored
May 20, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make a lot of pimp in the Forum
parent
ec307cd5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
215 additions
and
118 deletions
+215
-118
core/static/core/style.scss
core/static/core/style.scss
+118
-68
forum/templates/forum/forum.jinja
forum/templates/forum/forum.jinja
+10
-2
forum/templates/forum/last_unread.jinja
forum/templates/forum/last_unread.jinja
+9
-1
forum/templates/forum/macros.jinja
forum/templates/forum/macros.jinja
+44
-40
forum/templates/forum/main.jinja
forum/templates/forum/main.jinja
+20
-5
forum/templates/forum/topic.jinja
forum/templates/forum/topic.jinja
+2
-0
forum/views.py
forum/views.py
+12
-2
No files found.
core/static/core/style.scss
View file @
d7135e4d
...
...
@@ -48,8 +48,8 @@ a {
.ib
{
display
:
inline-block
;
padding
:
2
px
;
margin
:
2
px
;
padding
:
1
px
;
margin
:
1
px
;
}
.w_big
{
...
...
@@ -57,11 +57,11 @@ a {
}
.w_medium
{
width
:
4
5
%
;
width
:
4
7
%
;
}
.w_small
{
width
:
2
0
%
;
width
:
2
3
%
;
}
/*--------------------------------HEADER-------------------------------*/
...
...
@@ -271,11 +271,15 @@ code {
}
blockquote
{
margin
:
10
px
;
padding
:
5
px
;
margin
:
5
px
;
padding
:
2
px
;
border
:
solid
1px
$black-color
;
}
blockquote
h5
:first-child
{
font-size
:
100%
;
}
.edit-bar
{
display
:
block
;
margin
:
4px
;
...
...
@@ -498,86 +502,132 @@ textarea {
/*------------------------------FORUM----------------------------------*/
.topic
a
,
.forum
a
,
.category
a
{
color
:
$black-color
;
}
#forum
{
a
{
color
:
$black-color
;
}
.topic
a
:hover
,
.forum
a
:hover
,
.category
a
:hover
{
color
:
#424242
;
text-decoration
:
underline
;
}
a
:hover
{
color
:
#424242
;
text-decoration
:
underline
;
}
.topic
{
border
:
solid
$primary-neutral-color
1px
;
padding
:
2px
;
margin
:
2px
;
}
.topic
{
border
:
solid
$primary-neutral-color
1px
;
padding
:
1px
;
margin
:
1px
;
p
{
margin
:
1px
;
font-size
:
smaller
;
}
}
.forum
{
background
:
$primary-neutral-light-color
;
padding
:
2px
;
margin
:
2px
;
}
.tools
{
font-size
:
x-small
;
border
:
none
;
a
{
padding
:
1px
;
}
}
.category
{
background
:
$secondary-color
;
}
.title
{
font-size
:
small
;
font-weight
:
bold
;
padding
:
2px
;
}
.message
{
padding
:
2px
;
margin
:
2px
;
background
:
$white-color
;
&
:nth-child
(
odd
)
{
.last_message
date
{
white-space
:
nowrap
;
}
.last_message
span
{
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
overflow
:hidden
;
width
:
100%
;
display
:
block
;
}
.forum
{
background
:
$primary-neutral-light-color
;
padding
:
1px
;
margin
:
1px
;
p
{
margin
:
1px
;
font-size
:
smaller
;
}
}
h5
{
font-size
:
100%
;
.category
{
margin-top
:
5px
;
background
:
$secondary-color
;
.title
{
text-transform
:
uppercase
;
}
}
&
.unread
{
background
:
#d8e7f3
;
.message
{
padding
:
1px
;
margin
:
1px
;
background
:
$white-color
;
&
:nth-child
(
odd
)
{
background
:
$primary-neutral-light-color
;
}
.title
{
font-size
:
100%
;
}
&
.unread
{
background
:
#d8e7f3
;
}
}
}
.msg_author.deleted
{
background
:
#ffcfcf
;
}
.msg_author.deleted
{
background
:
#ffcfcf
;
}
.msg_content
{
&
.deleted
{
background
:
#ffefef
;
.msg_content
{
&
.deleted
{
background
:
#ffefef
;
}
display
:
inline-block
;
width
:
80%
;
vertical-align
:
top
;
}
display
:
inline-block
;
width
:
80%
;
vertical-align
:
top
;
}
.msg_author
{
display
:
inline-block
;
width
:
19%
;
text-align
:
center
;
background
:
$primary-light-color
;
img
{
max-width
:
70%
;
margin
:
0px
auto
;
.msg_author
{
display
:
inline-block
;
width
:
19%
;
text-align
:
center
;
background
:
$primary-light-color
;
img
{
max-width
:
70%
;
margin
:
0px
auto
;
}
}
}
.msg_meta
{
font-size
:
small
;
list-style-type
:
none
;
li
{
padding
:
2px
;
margin
:
2px
;
.msg_header
{
display
:
inline-block
;
width
:
100%
;
font-size
:
small
;
}
}
.forum_signature
{
color
:
#C0C0C0
;
border-top
:
1px
solid
#C0C0C0
;
a
{
.msg_meta
{
font-size
:
small
;
list-style-type
:
none
;
li
{
padding
:
1px
;
margin
:
1px
;
}
}
.forum_signature
{
color
:
#C0C0C0
;
&
:hover
{
text-decoration
:
underline
;
border-top
:
1px
solid
#C0C0C0
;
a
{
color
:
#C0C0C0
;
&
:hover
{
text-decoration
:
underline
;
}
}
}
}
...
...
forum/templates/forum/forum.jinja
View file @
d7135e4d
...
...
@@ -6,13 +6,14 @@
{%
endblock
%}
{%
block
content
%}
<div>
<div>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
{%
for
f
in
forum.get_parent_list
()
|
reverse
%}
>
<a
href=
"
{{
f.get_absolute_url
()
}}
"
>
{{
f
}}
</a>
{%
endfor
%}
>
<a
href=
"
{{
forum.get_absolute_url
()
}}
"
>
{{
forum
}}
</a>
</div>
</div>
<div
id=
"forum"
>
<h3>
{{
forum.name
}}
</h3>
<p>
{%
if
user.is_in_group
(
settings.SITH_GROUP_FORUM_ADMIN_ID
)
or
user.is_in_group
(
settings.SITH_GROUP_COM_ADMIN_ID
)
%}
...
...
@@ -34,6 +35,7 @@
</div>
</div>
</div>
{{
display_forum
(
forum
,
user
,
True
)
}}
{%
for
f
in
forum.children.all
()
%}
{{
display_forum
(
f
,
user
)
}}
{%
endfor
%}
...
...
@@ -58,7 +60,13 @@
{%
for
t
in
topics
%}
{{
display_topic
(
t
,
user
)
}}
{%
endfor
%}
<p
style=
"text-align: right; background: #d8e7f3;"
>
{%
for
p
in
topics.paginator.page_range
%}
<span
class=
"ib"
style=
"background:
{%
if
p
==
topics.
number
%}
white
{%
endif
%}
; margin: 0;"
><a
href=
"?topic_page=
{{
p
}}
"
>
{{
p
}}
</a></span>
{%
endfor
%}
</p>
{%
endif
%}
</div>
{%
endblock
%}
...
...
forum/templates/forum/last_unread.jinja
View file @
d7135e4d
...
...
@@ -15,9 +15,17 @@
<a
class=
"ib"
href=
"
{{
url
(
'forum:mark_all_as_read'
)
}}
"
>
{%
trans
%}
Mark all as read
{%
endtrans
%}
</a>
<a
class=
"ib"
href=
"
{{
url
(
'forum:last_unread'
)
}}
"
>
{%
trans
%}
Refresh
{%
endtrans
%}
</a>
</p>
{%
for
t
in
forumtopic
_list
%}
{%
for
t
in
page_obj.object
_list
%}
{{
display_topic
(
t
,
user
,
True
)
}}
{%
endfor
%}
<p
style=
"text-align: right; background: #d8e7f3;"
>
{%
for
p
in
paginator.page_range
%}
<span
class=
"ib"
style=
"background:
{%
if
p
==
paginator.
number
%}
white
{%
endif
%}
; margin: 0;"
>
<a
href=
"?page=
{{
p
}}
"
>
{{
p
}}
</a>
</span>
{%
endfor
%}
</p>
{%
endblock
%}
...
...
forum/templates/forum/macros.jinja
View file @
d7135e4d
{%
from
'core/macros.jinja'
import
user_profile_link
%}
{%
macro
display_forum
(
forum
,
user
)
%}
<div
class=
"forum
{%
if
forum.is_category
%}
category
{%
endif
%}
"
>
{%
macro
display_forum
(
forum
,
user
,
is_root
=
False
)
%}
<div
class=
"forum
{%
if
is_root
%}
category
{%
endif
%}
"
>
<div
class=
"ib w_big"
>
{%
if
not
forum.is_category
%}
{%
if
not
is_root
%}
<a
class=
"ib w_big"
href=
"
{{
url
(
'forum:view_forum'
,
forum_id
=
forum.id
)
}}
"
>
{%
else
%}
<div
class=
"ib w_big"
>
{%
endif
%}
<
h5
>
{{
forum.name
}}
</
h5
>
<
div
class=
"title"
>
{{
forum.name
}}
</
div
>
<p>
{{
forum.description
}}
</p>
{%
if
not
forum.is_category
%}
{%
if
not
is_root
%}
</a>
{%
else
%}
</div>
{%
endif
%}
{%
if
user.is_owner
(
forum
)
%}
<div
class=
"tools"
>
<a
class=
"ib"
href=
"
{{
url
(
'forum:edit_forum'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a>
<a
class=
"ib"
href=
"
{{
url
(
'forum:delete_forum'
,
forum_id
=
forum.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a>
</div>
{%
endif
%}
</div>
{%
if
not
forum.is_category
%}
{%
if
not
is_root
%}
<div
class=
"ib w_small"
>
<
div
class=
"ib w_medium"
>
<
p
class=
"ib w_medium"
>
{{
forum.topic_number
}}
</
div
>
<div
class=
"ib w_medium"
style=
"font-size: x-small; text-align: center"
>
</
p
>
<div
class=
"ib w_medium
last_message
"
style=
"font-size: x-small; text-align: center"
>
{%
if
forum.last_message
%}
{{
forum.last_message.author
}}
<br/>
<a
href=
"
{{
forum.last_message.get_absolute_url
()
}}
"
>
<date>
{{
forum.last_message.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
forum.last_message.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
<br/>
{{
forum.last_message.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</date><br>
<span>
{{
forum.last_message.topic
}}
</span>
</a>
{%
endif
%}
</div>
...
...
@@ -48,33 +54,33 @@
{%
else
%}
<a
class=
"ib w_big"
href=
"
{{
url
(
'forum:view_topic'
,
topic_id
=
topic.id
)
}}
"
>
{%
endif
%}
<
h5
>
{{
topic.title
}}
</
h5
>
<
div
class=
"title"
>
{{
topic.title
}}
</
div
>
<p>
{{
topic.description
}}
</p>
</a>
{%
if
user.can_edit
(
topic
)
%}
<div
class=
"ib"
style=
"text-align: center;"
>
<div
class=
"ib
tools
"
style=
"text-align: center;"
>
<a
href=
"
{{
url
(
'forum:edit_topic'
,
topic_id
=
topic.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a>
</div>
{%
endif
%}
</div>
<div
class=
"ib w_medium"
>
<div
class=
"ib w_medium
last_message
"
>
<div
class=
"ib w_medium"
>
<
div
class=
"ib w_medium"
style=
"text-align: center;"
>
<
p
class=
"ib w_medium"
style=
"text-align: center;"
>
{{
user_profile_link
(
topic.author
)
}}
</
div
>
<
div
class=
"ib w_medium"
style=
"text-align: center;"
>
</
p
>
<
p
class=
"ib w_medium"
style=
"text-align: center;"
>
{{
topic.messages.count
()
}}
</
div
>
</
p
>
</div>
<
div
class=
"ib w_medium"
style=
"text-align: center;"
>
<
p
class=
"ib w_medium"
style=
"text-align: center;"
>
{%
set
last_msg
=
topic.last_message
%}
{%
if
last_msg
%}
{{
user_profile_link
(
last_msg.author
)
}}
<br/>
<a
href=
"
{{
last_msg.get_absolute_url
()
}}
"
>
{{
last_msg.date
|
date
(
DATETIME_FORMAT
)
}}
{{
last_msg.date
|
time
(
DATETIME_FORMAT
)
}}
<date>
{{
last_msg.date
|
date
(
DATETIME_FORMAT
)
}}
{{
last_msg.date
|
time
(
DATETIME_FORMAT
)
}}
</date>
</a>
{%
endif
%}
</
div
>
</
p
>
</div>
</div>
{%
endmacro
%}
...
...
@@ -92,26 +98,24 @@
<strong><a
href=
"
{{
m.author.get_absolute_url
()
}}
"
>
{{
m.author.get_short_name
()
}}
</a></strong>
</div>
<div
class=
"msg_content
{%
if
m.deleted
%}
deleted
{%
endif
%}
"
{%
if
m.id
==
first_unread_message_id
%}
id=
"first_unread"
{%
endif
%}
>
<div
style=
"display: inline-block; width: 74%;"
>
{%
if
m.title
%}
<h5>
{{
m.title
}}
</h5>
{%
endif
%}
</div>
<div
style=
"display: inline-block; width: 25%;"
>
<span><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
m.topic.id
)
}}
?quote_id=
{{
m.id
}}
"
>
{%
trans
%}
Reply as quote
{%
endtrans
%}
</a></span>
{%
if
user.can_edit
(
m
)
%}
<span>
<a
href=
"
{{
url
(
'forum:edit_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
if
m.can_be_moderated_by
(
user
)
%}
{%
if
m.deleted
%}
<span>
<a
href=
"
{{
url
(
'forum:undelete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Undelete
{%
endtrans
%}
</a></span>
{%
else
%}
<span>
<a
href=
"
{{
url
(
'forum:delete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
endif
%}
<br/>
<span>
{{
m.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</span>
<div
class=
"msg_header"
>
<div
class=
"ib w_big title"
>
{{
m.title
}}
</div>
<div
class=
"ib w_small"
>
<span><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
m.topic.id
)
}}
?quote_id=
{{
m.id
}}
"
>
{%
trans
%}
Reply as quote
{%
endtrans
%}
</a></span>
{%
if
user.can_edit
(
m
)
%}
<span>
<a
href=
"
{{
url
(
'forum:edit_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Edit
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
if
m.can_be_moderated_by
(
user
)
%}
{%
if
m.deleted
%}
<span>
<a
href=
"
{{
url
(
'forum:undelete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Undelete
{%
endtrans
%}
</a></span>
{%
else
%}
<span>
<a
href=
"
{{
url
(
'forum:delete_message'
,
message_id
=
m.id
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a></span>
{%
endif
%}
{%
endif
%}
<br/>
<span>
{{
m.date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
m.date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</span>
</div>
</div>
<hr>
<div>
...
...
forum/templates/forum/main.jinja
View file @
d7135e4d
...
...
@@ -7,9 +7,10 @@
{%
endblock
%}
{%
block
content
%}
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
>
</p>
<p>
<a
href=
"
{{
url
(
'forum:main'
)
}}
"
>
{%
trans
%}
Forum
{%
endtrans
%}
</a>
>
</p>
<div
id=
"forum"
>
<h3>
{%
trans
%}
Forum
{%
endtrans
%}
</h3>
<p>
<a
class=
"ib"
href=
"
{{
url
(
'forum:last_unread'
)
}}
"
>
{%
trans
%}
View last unread messages
{%
endtrans
%}
</a>
...
...
@@ -19,14 +20,28 @@
<a
href=
"
{{
url
(
'forum:new_forum'
)
}}
"
>
{%
trans
%}
New forum
{%
endtrans
%}
</a>
</p>
{%
endif
%}
<div>
<div
class=
"ib w_big"
>
{%
trans
%}
Title
{%
endtrans
%}
</div>
<div
class=
"ib w_small"
>
<div
class=
"ib w_medium"
>
{%
trans
%}
Topics
{%
endtrans
%}
</div>
<div
class=
"ib w_small"
>
{%
trans
%}
Last message
{%
endtrans
%}
</div>
</div>
</div>
{%
for
f
in
forum_list
%}
<div
style=
"padding: 4px; margin: 4px"
>
{{
display_forum
(
f
,
user
)
}}
<div>
{{
display_forum
(
f
,
user
,
True
)
}}
{%
for
c
in
f.children.all
()
%}
{{
display_forum
(
c
,
user
)
}}
{%
endfor
%}
</div>
{%
endfor
%}
</div>
{%
endblock
%}
...
...
forum/templates/forum/topic.jinja
View file @
d7135e4d
...
...
@@ -35,6 +35,7 @@
>
<a
href=
"
{{
topic.get_absolute_url
()
}}
"
>
{{
topic
}}
</a>
</p>
<h3>
{{
topic.title
}}
</h3>
<div
id=
"forum"
>
<p>
{{
topic.description
}}
</p>
<p><a
href=
"
{{
url
(
'forum:new_message'
,
topic_id
=
topic.id
)
}}
"
>
{%
trans
%}
Reply
{%
endtrans
%}
</a></p>
...
...
@@ -62,6 +63,7 @@
<span
class=
"ib"
style=
"background:
{%
if
p
==
msgs.
number
%}
white
{%
endif
%}
; margin: 0;"
><a
href=
"?page=
{{
p
}}
"
>
{{
p
}}
</a></span>
{%
endfor
%}
</p>
</div>
{%
endblock
%}
...
...
forum/views.py
View file @
d7135e4d
...
...
@@ -59,6 +59,7 @@ class ForumMarkAllAsRead(RedirectView):
class
ForumLastUnread
(
ListView
):
model
=
ForumTopic
template_name
=
"forum/last_unread.jinja"
paginate_by
=
settings
.
SITH_FORUM_PAGE_LENGTH
/
2
def
get_queryset
(
self
):
l
=
ForumMessage
.
objects
.
exclude
(
readers
=
self
.
request
.
user
).
filter
(
...
...
@@ -117,7 +118,16 @@ class ForumDetailView(CanViewMixin, DetailView):
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
ForumDetailView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'topics'
]
=
self
.
object
.
topics
.
annotate
(
models
.
Max
(
'messages__date'
)).
order_by
(
'-messages__date__max'
)
qs
=
self
.
object
.
topics
.
order_by
(
'-_last_message__date'
).
select_related
(
'_last_message'
)
paginator
=
Paginator
(
qs
,
settings
.
SITH_FORUM_PAGE_LENGTH
)
page
=
self
.
request
.
GET
.
get
(
'topic_page'
)
try
:
kwargs
[
"topics"
]
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
kwargs
[
"topics"
]
=
paginator
.
page
(
1
)
except
EmptyPage
:
kwargs
[
"topics"
]
=
paginator
.
page
(
paginator
.
num_pages
)
return
kwargs
class
TopicForm
(
forms
.
ModelForm
):
...
...
@@ -164,7 +174,7 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
kwargs
[
'first_unread_message_id'
]
=
msg
.
id
except
:
kwargs
[
'first_unread_message_id'
]
=
float
(
"inf"
)
paginator
=
Paginator
(
self
.
object
.
messages
.
select_related
(
'author__avatar_pict'
).
all
(
),
paginator
=
Paginator
(
self
.
object
.
messages
.
select_related
(
'author__avatar_pict'
).
order_by
(
'date'
),
settings
.
SITH_FORUM_PAGE_LENGTH
)
page
=
self
.
request
.
GET
.
get
(
'page'
)
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment