Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink authored Sep 11, 2021
2 parents 0b73a38 + 7608ec8 commit 3168343
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
8 changes: 4 additions & 4 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-r requirements.txt

black==21.4b1 # penser à mettre à jour aussi .github/workflows/ci.yml
colorlog==5.0.1
django-debug-toolbar==3.2.1
colorlog==6.4.1
django-debug-toolbar==3.2.2
django-extensions==3.1.3
Faker==8.2.1
pre-commit==2.13.0
Faker==8.12.1
pre-commit==2.15.0
PyYAML==5.4.1
selenium==3.141.0
Sphinx==3.5.3
Expand Down
4 changes: 2 additions & 2 deletions requirements-prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

gunicorn==20.1.0
mysqlclient==2.0.3
sentry-sdk==1.1.0
ujson==4.0.2
sentry-sdk==1.3.1
ujson==4.1.0
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
elasticsearch-dsl==5.4.0
elasticsearch==5.5.3
python-social-auth==0.3.6
social-auth-app-django==4.0.0
social-auth-app-django==5.0.0

# Explicit dependencies (references in code)
beautifulsoup4==4.9.3
django-crispy-forms==1.11.2
django-crispy-forms==1.12.0
django-model-utils==4.1.1
django-munin==0.2.1
django-recaptcha==2.0.6
Expand All @@ -18,19 +18,19 @@ GitPython==3.1.14
google-api-python-client==1.12.8
homoglyphs==2.0.4
lxml==4.6.3
Pillow==8.2.0
Pillow==8.3.2
python-memcached==1.59
requests==2.25.1
requests==2.26.0
toml==0.10.2

# Api dependencies
django-cors-headers==3.7.0
django-cors-headers==3.8.0
django-filter==2.4.0
django-oauth-toolkit==1.5.0
django-rest-swagger==2.2.0
djangorestframework-xml==2.0.0
djangorestframework==3.12.4
drf-extensions==0.7.0
drf-extensions==0.7.1
dry-rest-permissions==0.1.10
oauth2client==4.1.3

Expand Down
13 changes: 7 additions & 6 deletions zds/tutorialv2/publication_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,12 @@ def publish(self, md_file_path, base_name, **kwargs):
licence_logo = licences["copyright"]
licence_url = ""

replacement_image_url = str(settings.MEDIA_ROOT)
if not replacement_image_url.endswith("/") and settings.MEDIA_URL.endswith("/"):
replacement_image_url = str(settings.MEDIA_ROOT.parent)
if not replacement_image_url.endswith("/"):
replacement_image_url += "/"
elif replacement_image_url.endswith("/") and not settings.MEDIA_URL.endswith("/"):
replacement_image_url = replacement_image_url[:-1]
replaced_media_url = settings.MEDIA_URL
if replaced_media_url.startswith("/"):
replaced_media_url = replaced_media_url[1:]
exported = export_content(public_versionned_source, with_text=True)
# no title to avoid zmd to put it on the final latex
del exported["title"]
Expand All @@ -423,13 +424,13 @@ def publish(self, md_file_path, base_name, **kwargs):
license_url=licence_url,
smileys_directory=str(SMILEYS_BASE_PATH / "svg"),
images_download_dir=str(base_directory / "images"),
local_url_to_local_path=[settings.MEDIA_URL, replacement_image_url],
local_url_to_local_path=["/", replacement_image_url],
heading_shift=-1,
)
if content == "" and messages:
raise FailureDuringPublication(f"Markdown was not parsed due to {messages}")
zmd_class_dir_path = Path(settings.ZDS_APP["content"]["latex_template_repo"])

content.replace(replacement_image_url + replaced_media_url, replacement_image_url)
if zmd_class_dir_path.exists() and zmd_class_dir_path.is_dir():
with contextlib.suppress(FileExistsError):
zmd_class_link = base_directory / "zmdocument.cls"
Expand Down
26 changes: 19 additions & 7 deletions zds/utils/templatetags/emarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def log_args():
return "", {}, []


def render_markdown(md_input, *, on_error=None, **kwargs):
def render_markdown(md_input, *, on_error=None, disable_jsfiddle=True, **kwargs):
"""Render a markdown string.
Returns a tuple ``(rendered_content, metadata)``, where
Expand All @@ -102,7 +102,9 @@ def render_markdown(md_input, *, on_error=None, **kwargs):
(without any technical details).
"""
content, metadata, messages = _render_markdown_once(md_input, **kwargs)
opts = {"disable_jsfiddle": disable_jsfiddle}
opts.update(kwargs)
content, metadata, messages = _render_markdown_once(md_input, **opts)
if messages and on_error:
on_error([m["message"] for m in messages])
if content is not None:
Expand Down Expand Up @@ -145,11 +147,21 @@ def render_markdown_stats(md_input, **kwargs):

@register.filter(name="epub_markdown", needs_autoescape=False)
def epub_markdown(md_input, image_directory):
return emarkdown(
md_input,
output_format="epub",
images_download_dir=image_directory.absolute,
local_url_to_local_path=[settings.MEDIA_URL + "galleries/[0-9]+", image_directory.relative],
media_root = str(settings.MEDIA_ROOT)
if not media_root.endswith("/"):
media_root += "/"
replaced_media_url = settings.MEDIA_URL
if replaced_media_url.startswith("/"):
replaced_media_url = replaced_media_url[1:]
return (
emarkdown(
md_input,
output_format="epub",
images_download_dir=image_directory.absolute,
local_url_to_local_path=[settings.MEDIA_URL + "galleries/[0-9]+", image_directory.relative],
)
.replace('src"/', f'src="{media_root}')
.replace(f'src="{media_root}{replaced_media_url}', f'src="{media_root}')
)


Expand Down
2 changes: 1 addition & 1 deletion zmd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"zmarkdown": "10.1.2"
"zmarkdown": "10.1.3"
},
"engines": {
"node": ">=8.0.0"
Expand Down

0 comments on commit 3168343

Please sign in to comment.