Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
proto3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
protokollsystem
proto3
Commits
74811e3d
Commit
74811e3d
authored
8 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Generate infobox-template for mediawiki
parent
e918b00e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
models/database.py
+6
-0
6 additions, 0 deletions
models/database.py
tasks.py
+27
-5
27 additions, 5 deletions
tasks.py
templates/infobox.wiki
+11
-0
11 additions, 0 deletions
templates/infobox.wiki
templates/protocol.wiki
+24
-43
24 additions, 43 deletions
templates/protocol.wiki
wiki.py
+1
-1
1 addition, 1 deletion
wiki.py
with
69 additions
and
49 deletions
models/database.py
+
6
−
0
View file @
74811e3d
...
@@ -115,6 +115,12 @@ class ProtocolType(db.Model):
...
@@ -115,6 +115,12 @@ class ProtocolType(db.Model):
if
protocoltype
.
has_private_view_right
(
user
)
if
protocoltype
.
has_private_view_right
(
user
)
]
]
def
get_wiki_infobox
(
self
):
return
"
Infobox {}
"
.
format
(
self
.
short_name
)
def
get_wiki_infobox_title
(
self
):
return
"
Vorlage:{}
"
.
format
(
self
.
get_wiki_infobox
())
class
Protocol
(
db
.
Model
):
class
Protocol
(
db
.
Model
):
__tablename__
=
"
protocols
"
__tablename__
=
"
protocols
"
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
...
...
This diff is collapsed.
Click to expand it.
tasks.py
+
27
−
5
View file @
74811e3d
...
@@ -45,6 +45,23 @@ mailenv.filters["url_complete"] = url_manager.complete
...
@@ -45,6 +45,23 @@ mailenv.filters["url_complete"] = url_manager.complete
mailenv
.
filters
[
"
datify
"
]
=
date_filter
mailenv
.
filters
[
"
datify
"
]
=
date_filter
mailenv
.
filters
[
"
datetimify
"
]
=
datetime_filter
mailenv
.
filters
[
"
datetimify
"
]
=
datetime_filter
wikienv
=
app
.
create_jinja_environment
()
wikienv
.
trim_blocks
=
True
wikienv
.
lstrip_blocks
=
True
wikienv
.
block_start_string
=
"
<env>
"
wikienv
.
block_end_string
=
"
</env>
"
wikienv
.
variable_start_string
=
"
<var>
"
wikienv
.
variable_end_string
=
"
</var>
"
wikienv
.
comment_start_string
=
"
<comment>
"
wikienv
.
comment_end_string
=
"
</comment>
"
wikienv
.
filters
[
"
datify
"
]
=
date_filter
wikienv
.
filters
[
"
datify_long
"
]
=
date_filter_long
wikienv
.
filters
[
"
datify_short
"
]
=
date_filter_short
wikienv
.
filters
[
"
datetimify
"
]
=
datetime_filter
wikienv
.
filters
[
"
timify
"
]
=
time_filter
wikienv
.
filters
[
"
class
"
]
=
class_filter
ID_FIELD_BEGINNING
=
"
id
"
ID_FIELD_BEGINNING
=
"
id
"
def
parse_protocol
(
protocol
,
**
kwargs
):
def
parse_protocol
(
protocol
,
**
kwargs
):
...
@@ -285,19 +302,24 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
...
@@ -285,19 +302,24 @@ def parse_protocol_async_inner(protocol, encoded_kwargs):
compile
(
latex_source
,
protocol
,
show_private
=
show_private
,
maxdepth
=
maxdepth
)
compile
(
latex_source
,
protocol
,
show_private
=
show_private
,
maxdepth
=
maxdepth
)
if
protocol
.
protocoltype
.
use_wiki
:
if
protocol
.
protocoltype
.
use_wiki
:
wiki_source
=
render_template
(
"
protocol.wiki
"
,
render_type
=
RenderType
.
wikitext
,
show_private
=
not
protocol
.
protocoltype
.
wiki_only_public
,
**
render_kwargs
).
replace
(
"
\n\n\n
"
,
"
\n\n
"
)
wiki_source
=
wikienv
.
get_template
(
"
protocol.wiki
"
).
render
(
render_type
=
RenderType
.
wikitext
,
show_private
=
not
protocol
.
protocoltype
.
wiki_only_public
,
**
render_kwargs
).
replace
(
"
\n\n\n
"
,
"
\n\n
"
)
push_to_wiki
(
protocol
,
wiki_source
,
"
Automatisch generiert vom Protokollsystem 3.0
"
)
wiki_infobox_source
=
wikienv
.
get_template
(
"
infobox.wiki
"
).
render
(
protocoltype
=
protocol
.
protocoltype
)
push_to_wiki
(
protocol
,
wiki_source
,
wiki_infobox_source
,
"
Automatisch generiert vom Protokollsystem 3.0
"
)
protocol
.
done
=
True
protocol
.
done
=
True
db
.
session
.
commit
()
db
.
session
.
commit
()
def
push_to_wiki
(
protocol
,
content
,
summary
):
def
push_to_wiki
(
protocol
,
content
,
infobox_content
,
summary
):
push_to_wiki_async
.
delay
(
protocol
.
id
,
content
,
summary
)
push_to_wiki_async
.
delay
(
protocol
.
id
,
content
,
infobox_content
,
summary
)
@celery.task
@celery.task
def
push_to_wiki_async
(
protocol_id
,
content
,
summary
):
def
push_to_wiki_async
(
protocol_id
,
content
,
infobox_content
,
summary
):
with
WikiClient
()
as
wiki_client
,
app
.
app_context
():
with
WikiClient
()
as
wiki_client
,
app
.
app_context
():
protocol
=
Protocol
.
query
.
filter_by
(
id
=
protocol_id
).
first
()
protocol
=
Protocol
.
query
.
filter_by
(
id
=
protocol_id
).
first
()
try
:
try
:
wiki_client
.
edit_page
(
title
=
protocol
.
protocoltype
.
get_wiki_infobox_title
(),
content
=
infobox_content
,
summary
=
"
Automatisch generiert vom Protokollsystem 3.
"
)
wiki_client
.
edit_page
(
wiki_client
.
edit_page
(
title
=
protocol
.
get_wiki_title
(),
title
=
protocol
.
get_wiki_title
(),
content
=
content
,
content
=
content
,
...
...
This diff is collapsed.
Click to expand it.
templates/infobox.wiki
0 → 100644
+
11
−
0
View file @
74811e3d
{{Infobox
| Titel = {{{name|<includeonly>{{PAGENAMEBASE}}</includeonly>}}}
| Feldname1 = Datum
| Daten1 = {{{datum|}}}
| Feldname2 = Zeit
| Daten2 = {{{zeit|}}}
<env> for meta in protocoltype.metas </env>
| Feldname<var>loop.index + 2</var> = <var>meta.name</var>
| Daten<var>loop.index + 2</var> = {{{<var>meta.name|lower</var>|}}}
<env> endfor </env>
}}
This diff is collapsed.
Click to expand it.
templates/protocol.wiki
+
24
−
43
View file @
74811e3d
{#
{{<var>protocol.protocoltype.get_wiki_infobox()</var>
{{'{{'}}Infobox Protokoll
| name = <var>protocol.protocoltype.name</var>
| name = {{protocol.protocoltype.name}}
<env> if protocol.date is not none </env>
{% if protocol.date is not none %}
| datum = <var>protocol.date|datify_long</var>
| datum = {{protocol.date|datify_long}}
<env> endif </env>
{% endif %}
<env> if protocol.start_time is not none and protocol.end_time is not none </env>
{% if protocol.start_time is not none and protocol.end_time is not none %}
| zeit = von <var>protocol.start_time|timify</var> bis <var>protocol.end_time|timify</var>
| zeit = von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}
<env> endif </env>
{% endif %}
<env> for meta in protocol.metas </env>
{% if protocol.author is not none %}
| <var>meta.name|lower</var> = <var>meta.value</var>
| protokollant = {{protocol.author}}
<env> endfor </env>
{% endif %}
}}
{% if protocol.participants is not none %}
| anwesende = {{protocol.participants}}
{% endif %}
{{'}}'}}
#}
'''{{protocol.protocoltype.name}}'''
{% if protocol.date is not none %}
Datum: '''{{protocol.date|datify_long}}'''
{% endif %}
{% if protocol.start_time is not none and protocol.end_time is not none %}
Zeit: '''von {{protocol.start_time|timify}} bis {{protocol.end_time|timify}}'''
{% endif %}
{% for meta in protocol.metas %}
{{meta.name}}: '''{{meta.value}}'''
{% endfor %}
== Beschlüsse ==
== Beschlüsse ==
{%
if protocol.decisions|length > 0
%}
<env>
if protocol.decisions|length > 0
</env>
{%
for decision in protocol.decisions
%}
<env>
for decision in protocol.decisions
</env>
*
{{
decision.content
}}
*
<var>
decision.content
</var>
{%
endfor
%}
<env>
endfor
</env>
{%
else
%}
<env>
else
</env>
* keine Beschlüsse
* keine Beschlüsse
{%
endif
%}
<env>
endif
</env>
{%
for top in tree.children
%}
<env>
for top in tree.children
</env>
{%
if top|class == "Fork"
%}
<env>
if top|class == "Fork"
</env>
{{
top.render(render_type=render_type, level=0, show_private=show_private, protocol=protocol)
}}
<var>
top.render(render_type=render_type, level=0, show_private=show_private, protocol=protocol)
</var>
{%
endif
%}
<env>
endif
</env>
{%
endfor
%}
<env>
endfor
</env>
[[Kategorie:
{{
protocol.protocoltype.wiki_category
}}
]]
[[Kategorie:
<var>
protocol.protocoltype.wiki_category
</var>
]]
This diff is collapsed.
Click to expand it.
wiki.py
+
1
−
1
View file @
74811e3d
...
@@ -95,7 +95,7 @@ class WikiClient:
...
@@ -95,7 +95,7 @@ class WikiClient:
req
=
requests
.
post
(
self
.
endpoint
,
cookies
=
self
.
cookies
,
data
=
data
,
params
=
params
)
req
=
requests
.
post
(
self
.
endpoint
,
cookies
=
self
.
cookies
,
data
=
data
,
params
=
params
)
if
req
.
status_code
!=
HTTP_STATUS_OK
:
if
req
.
status_code
!=
HTTP_STATUS_OK
:
raise
WikiException
(
"
HTTP status code {} on action {}.
"
.
format
(
req
.
status_code
,
action
))
raise
WikiException
(
"
HTTP status code {} on action {}.
"
.
format
(
req
.
status_code
,
action
))
self
.
cookies
=
req
.
cookies
self
.
cookies
.
update
(
req
.
cookies
)
return
req
.
json
()
return
req
.
json
()
def
main
():
def
main
():
...
...
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