Skip to content

Commit

Permalink
Rename file extension of Jinja2 templates: html -> jinja2
Browse files Browse the repository at this point in the history
  • Loading branch information
Smibu committed Dec 15, 2020
1 parent fbec80f commit 4cd59cd
Show file tree
Hide file tree
Showing 35 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion timApp/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def login():
if logged_in():
flash('You are already logged in.')
return safe_redirect(session.get('came_from', '/'))
return render_template('loginpage.html',
return render_template('loginpage.jinja2',
text='Please use the above button to log in.',
anchor=request.args.get('anchor'))

Expand Down
4 changes: 2 additions & 2 deletions timApp/document/editing/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,14 +463,14 @@ def par_response(pars: List[DocParagraph],
for p, r in zip(post_process_result.texts, proofed_text):
p['html'] = r.new_html

r = json_response({'texts': render_template('partials/paragraphs.html',
r = json_response({'texts': render_template('partials/paragraphs.jinja2',
text=post_process_result.texts,
item={'rights': get_rights(doc.get_docinfo())},
preview=preview),
'js': post_process_result.js_paths,
'css': post_process_result.css_paths,
'trdiff': trdiff,
'changed_pars': {p['id']: render_template('partials/paragraphs.html',
'changed_pars': {p['id']: render_template('partials/paragraphs.jinja2',
text=[p],
item={'rights': get_rights(doc.get_docinfo())}) for p
in
Expand Down
4 changes: 2 additions & 2 deletions timApp/errorhandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def handle_already_exists(error: ItemAlreadyExistsException):

@app.errorhandler(DumboHTMLException)
def handle_dumbo_html_exception(error: DumboHTMLException):
return error_generic(error.description, 400, template='dumbo_html_error.html')
return error_generic(error.description, 400, template='dumbo_html_error.jinja2')

@app.errorhandler(ItemLockedException)
def handle_item_locked(error: ItemLockedException):
Expand All @@ -72,7 +72,7 @@ def handle_item_locked(error: ItemLockedException):
abort(404)
view_settings = get_minimal_visibility_settings(item.document if not is_folder else None)
return render_template(
'duration_unlock.html',
'duration_unlock.jinja2',
item=item,
item_type='folder' if is_folder else 'document',
access=error.access,
Expand Down
4 changes: 2 additions & 2 deletions timApp/folder/folder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def try_return_folder(item_name):
db.session.commit()
return view(item_name, ViewRoute.View)

return render_template('create_new.html',
return render_template('create_new.jinja2',
show_create_new=get_current_user_object().can_write_to_folder(f),
new_item=item_name,
found_item=f,
forced_template=template_to_find if template_item else None), 404
verify_view_access(f)
return render_template(
'index.html',
'index.jinja2',
item=f,
items=get_items(item_name),
)
2 changes: 1 addition & 1 deletion timApp/item/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def manage(path):
item.changelog_length = get_option(request, 'history', 100)

return render_template(
'manage.html',
'manage.jinja2',
route='manage',
translations=item.translations if not is_folder else None,
item=item,
Expand Down
12 changes: 6 additions & 6 deletions timApp/item/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def items_route(args: GetItemsModel):
@view_page.route("/view")
def index_page():
save_last_page()
return render_template('index.html',
return render_template('index.jinja2',
items=get_items(''),
item=Folder.get_root())

Expand All @@ -260,7 +260,7 @@ def get_module_ids(js_paths: List[str]):


def goto_view(item_path, model: ViewParams):
return render_template('goto_view.html',
return render_template('goto_view.jinja2',
item_path=item_path,
display_text=model.goto,
wait_max=model.wait_max,
Expand Down Expand Up @@ -330,7 +330,7 @@ def view(item_path: str, route: ViewRoute) -> FlaskViewResult:
result = cr.doc

final_html = render_template(
'show_slide.html' if view_ctx.route == ViewRoute.ShowSlide else 'view_html.html',
'show_slide.jinja2' if view_ctx.route == ViewRoute.ShowSlide else 'view_html.jinja2',
access=access,
doc_content=result.content_html,
doc_head=result.head_html,
Expand Down Expand Up @@ -611,7 +611,7 @@ def render_doc_view(
document_themes = list(set().union(document_themes, user_themes))
override_theme = generate_theme(document_themes, get_default_scss_gen_dir())

templates_to_render = ['slide_head.html', 'slide_content.html'] if is_slide else ['doc_head.html', 'doc_content.html']
templates_to_render = ['slide_head.jinja2', 'slide_content.jinja2'] if is_slide else ['doc_head.jinja2', 'doc_content.jinja2']
tmpl_params = dict(
access=access,
hide_links=should_hide_links(doc_settings, rights),
Expand Down Expand Up @@ -673,7 +673,7 @@ def render_login(item: Optional[Document]) -> FlaskViewResult:
view_settings = get_minimal_visibility_settings(item)
session['came_from'] = request.url
session['anchor'] = request.args.get('anchor', '')
return render_template('loginpage.html',
return render_template('loginpage.jinja2',
came_from=request.full_path,
anchor=session['anchor'],
view_settings=view_settings), 403
Expand Down Expand Up @@ -757,7 +757,7 @@ def check_updated_pars(doc_id, major, minor):
view_ctx,
)
diff['content'] = {
'texts': render_template('partials/paragraphs.html',
'texts': render_template('partials/paragraphs.jinja2',
text=post_process_result.texts,
item={'rights': rights},
preview=False),
Expand Down
2 changes: 1 addition & 1 deletion timApp/lecture/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def show_lecture_info(lecture_id):
raise RouteException('Lecture not found')

doc = DocEntry.find_by_id(lecture.doc_id)
return render_template("lectureInfo.html",
return render_template("lectureInfo.jinja2",
item=doc,
lecture=lecture,
translations=doc.translations)
Expand Down
2 changes: 1 addition & 1 deletion timApp/static/scripts/tim/document/viewctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export class ViewCtrl implements IController {
return p.startsWith("/slidefff/") || p.startsWith("/show_slide/");
}

// noinspection JSUnusedGlobalSymbols (used in view_html.html)
// noinspection JSUnusedGlobalSymbols (used in view_html.jinja2)
showVelpSelection() {
return (
(this.reviewCtrl.velpMode ||
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion timApp/templates/create_new.html → timApp/templates/create_new.jinja2
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block title %}This page does not yet exist.{% endblock %}
{% block content %}
<p class="errormsg">{{ message or self.title() }}</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "error.html" %}
{% extends "error.jinja2" %}
{% block content %}
<p>
The markdown server failed to render markdown to HTML. This usually means that the mathematical formulas
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'item.html' %}
{% extends 'item.jinja2' %}
{% block head %}
{{ super() }}
{% if view_settings %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block title %}{{ code }} {{ status }}{% endblock %}
{% block content %}
<p class="errormsg">{{ message }}</p>
Expand Down
1 change: 0 additions & 1 deletion timApp/templates/folder.html

This file was deleted.

1 change: 1 addition & 0 deletions timApp/templates/folder.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends 'item.jinja2' %}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "folder.html" %}
{% extends "folder.jinja2" %}
{% block title %}{{'{} {}'.format(item.title, '({})'.format(item.location) if item.location else '')}}{% endblock %}
{% block head %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'base.jinja2' %}
{% block head %}
{{ super() }}
<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "item.html" %}
{% extends "item.jinja2" %}
{% block title %}Lecture info{% endblock %}
{% block head %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block title %}Login{% endblock %}
{% block head %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'item.html' %}
{% extends 'item.jinja2' %}
{% block title %}{{ item.title }} - Manage{% endblock %}
{% block head %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
{% else %}
<div id="pars">
{% include 'partials/paragraphs.html' %}
{% include 'partials/paragraphs.jinja2' %}
<div ng-cloak class="addBottomContainer hidden-print" ng-show="$ctrl.item.rights.editable"
ng-class="{'height-35': $ctrl.editing}">
{% set btntext = doc_settings.add_par_button_text() %}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'partials/doc_head.html' %}
{% extends 'partials/doc_head.jinja2' %}

{% block content %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "base.html" %}
{% extends "base.jinja2" %}
{% block title %}Settings{% endblock %}
{% block head %}
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'view_html.html' %}
{% extends 'view_html.jinja2' %}

{% block body %}
<tim-view>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'base.jinja2' %}
{% block title %}Welcome{% endblock %}

{% block content %}
Expand Down
2 changes: 1 addition & 1 deletion timApp/templates/view_html.html → timApp/templates/view_html.jinja2
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "item.html" %}
{% extends "item.jinja2" %}
{% set teacher_mode = route in ("teacher", "answers") %}
{% block title %}{{ item.title }}{% endblock %}

Expand Down
2 changes: 1 addition & 1 deletion timApp/tests/server/timroutetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def create_folder(self, path: str, title: str = 'foldertitle', expect_status=200

def assert_js_variable(self, element: HtmlElement, variable_name: str, expect_content: Any):
"""
Check a JavaScript variable from view_html.html.
Check a JavaScript variable from view_html.jinja2.
:param element: HTML-tree.
:param variable_name: Variable name as it's in the <script>.
:param expect_content: Expected content.
Expand Down
2 changes: 1 addition & 1 deletion timApp/tim.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def update_user_course_bookmarks():
def start_page():
update_user_course_bookmarks()
return render_template(
'start.html',
'start.jinja2',
)


Expand Down
4 changes: 4 additions & 0 deletions timApp/tim_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@

app.jinja_env.auto_reload = True # uncomment this to autoreload templates

# The autoescape setting needs to be forced because the template file extension used in TIM is jinja2.
# The more accurate file extension helps IDEs recognize the file type better.
app.jinja_env.autoescape = True

app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
app.config.from_pyfile('defaultconfig.py', silent=False)
Expand Down
2 changes: 1 addition & 1 deletion timApp/user/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def show() -> str:

try:
limit = 50
return render_template('settings.html',
return render_template('settings.jinja2',
css_files=available_css_files,
notification_limit=limit,
notifications=get_current_user_notifications(limit=limit))
Expand Down
2 changes: 1 addition & 1 deletion timApp/util/flask/responsehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def csv_response(data, dialect='excel', delimiter=','):
return Response(stream_with_context(iter_csv(data, dialect, delimiter)), mimetype='text/plain')


def error_generic(error: str, code: int, template='error.html'):
def error_generic(error: str, code: int, template='error.jinja2'):
if 'text/html' in request.headers.get("Accept", ""):
return render_template(template,
message=error,
Expand Down

0 comments on commit 4cd59cd

Please sign in to comment.