Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
warpinfra
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian
warpinfra
Commits
96a69be0
Commit
96a69be0
authored
8 years ago
by
Christian Dresen
Browse files
Options
Downloads
Patches
Plain Diff
[WarpMain] Added Markdown Support for News. Closed #30
parent
a39c79b9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
www/Dockerfile
+1
-0
1 addition, 0 deletions
www/Dockerfile
www/web/warpmain/templates/warpmain/main.html
+18
-1
18 additions, 1 deletion
www/web/warpmain/templates/warpmain/main.html
www/web/warpmain/views.py
+7
-1
7 additions, 1 deletion
www/web/warpmain/views.py
with
26 additions
and
2 deletions
www/Dockerfile
+
1
−
0
View file @
96a69be0
...
...
@@ -31,6 +31,7 @@ RUN pip3 install \
uwsgi
\
django-two-factor-auth
\
matterhook
\
markdown
\
--upgrade
RUN
pip3
install
git+https://github.com/nkunihiko/django-bootstrap3-datetimepicker.git
...
...
This diff is collapsed.
Click to expand it.
www/web/warpmain/templates/warpmain/main.html
+
18
−
1
View file @
96a69be0
...
...
@@ -21,7 +21,24 @@
</div>
</div>
</form>
<div
class=
"panel-body"
>
<H4>
{%trans "markdown_support" %}
</H4>
<pre>
# h1
## h2
### h3
#### h4
1. Ordered item 1
2. Ordered item 2
* Unordered item 1
* Unordered item 2
</pre>
<br>
</div>
</div>
</div>
{% endif %}
{% for news in news_list %}
...
...
@@ -30,7 +47,7 @@
<span
class=
"lead"
>
{{ news.title }}
</span><div
class=
"pull-right"
>
{% if user.is_superuser %}
<a
href=
"/news/delete/{{ news.id }}"
class=
"btn btn-danger"
><span
class=
"glyphicon glyphicon-trash"
></span></a>
{% endif %}
</div>
</div>
<div
class=
"panel-body"
>
{{ news.message|
linebreaksbr
}}
{{ news.message|
safe
}}
</div>
<div
class=
"panel-footer"
>
{% trans "created_by" %} {{ news.user }} {{ news.created | naturaltime }}
...
...
This diff is collapsed.
Click to expand it.
www/web/warpmain/views.py
+
7
−
1
View file @
96a69be0
...
...
@@ -5,6 +5,8 @@ from warpmain.models import News, NewsForm
from
django.shortcuts
import
render
,
redirect
from
django.contrib.auth.decorators
import
login_required
from
warpzone.util
import
send_to_mattermost
import
markdown
from
django.utils.html
import
escape
@login_required
(
login_url
=
settings
.
LOGIN_URL
,
redirect_field_name
=
None
)
def
index
(
request
,
news_id
=
0
):
...
...
@@ -26,7 +28,11 @@ def index(request, news_id=0):
news_form
=
NewsForm
(
News
.
objects
.
get
(
id
=
news_id
))
page_context
[
'
create_news_form
'
]
=
news_form
page_context
[
'
news_list
'
]
=
News
.
objects
.
order_by
(
"
-created
"
)
page_context
[
'
news_list
'
]
=
[]
news_list
=
News
.
objects
.
order_by
(
"
-created
"
)
for
news
in
news_list
:
news
.
message
=
markdown
.
markdown
(
escape
(
news
.
message
),
extensions
=
[
'
markdown.extensions.nl2br
'
,
'
markdown.extensions.sane_lists
'
])
page_context
[
'
news_list
'
].
append
(
news
)
return
HttpResponse
(
render
(
request
,
'
warpmain/main.html
'
,
page_context
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment