Skip to content

Commit

Permalink
fix: updated the exported readme to include default upload path and i…
Browse files Browse the repository at this point in the history
…mage-asset-folder attribute
  • Loading branch information
deltork committed Jun 5, 2024
1 parent 6ac285f commit 469f9ec
Show file tree
Hide file tree
Showing 4 changed files with 649 additions and 641 deletions.
2 changes: 1 addition & 1 deletion readalongs/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.20240404"
__version__ = "1.0.20240426"
5 changes: 3 additions & 2 deletions readalongs/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def align_audio(
final_end = aligned_words[-1]["end"]
if len(aligned_words) != len(word_sequence.words):
LOGGER.warning(
f"Word sequence {i+1} had {len(word_sequence.words)} tokens "
f"Word sequence {i + 1} had {len(word_sequence.words)} tokens "
f"but produced {len(aligned_words)} segments. "
"Check that the anchors are well positioned or "
"that the audio corresponds to the text."
Expand Down Expand Up @@ -979,7 +979,7 @@ def save_readalong(
if "images" in config:
save_images(config=config, output_dir=output_dir)
save_readme_txt(
os.path.join(output_dir, "README.txt"),
os.path.join(output_dir, "readme.txt"),
os.path.basename(ras_path),
os.path.basename(audio_path),
config.get("header", "Header goes here"),
Expand Down Expand Up @@ -1154,6 +1154,7 @@ def convert_to_xhtml(tokenized_xml, title="Book"):
head.append(link_element)


# TODO: add this <!-- DO NOT USE THIS DATA WITHOUT EXPLICIT PERMISSION --> to template
RAS_TEMPLATE = """<?xml version='1.0' encoding='utf-8'?>
<read-along version="1.0">
<text xml:lang="{{main_lang}}" fallback-langs="{{fallback_langs}}">
Expand Down
28 changes: 17 additions & 11 deletions readalongs/text/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import re
import zipfile
from collections import OrderedDict
from datetime import datetime
from io import TextIOWrapper
from typing import IO, Union
from unicodedata import normalize
Expand Down Expand Up @@ -212,8 +213,8 @@ def copy_file_to_zip(zip_path, origin_path, destination_path):
</head>
<body>
<!-- Here is how you declare the Web Component. Supported languages: en, fr -->
<read-along href="{text}" audio="{audio}" theme="{theme}" language="en">
<!-- Here is how you declare the Web Component. Supported languages: eng, fra, spa -->
<read-along href="{text}" audio="{audio}" theme="{theme}" language="eng">
<span slot='read-along-header'>{header}</span>
<span slot='read-along-subheader'>{subheader}</span>
</read-along>
Expand Down Expand Up @@ -321,27 +322,28 @@ def parse_time(time_string: str) -> int:
Setup the plugin (do this once)
Install and activate our plugin 'wp-read-along-web-app-loader' on your WordPress site.
Install and activate our plugin 'read-along-web-app-loader' on your WordPress site.
See https://github.com/ReadAlongs/Studio-Web/tree/main/packages/web-component/wordpress-plugin for more information
Deploy the read-along
Upload the {text} and {audio} to your Media Library of your WordPress site.
Upload the images and {text} and {audio} to your Media Library of your WordPress site.
Use the text editor to paste the snippet below in your WordPress page
Replace assets/ with the path from your Media Library
---- WP Deployment SNIPPET ----
<!-- Here is how you declare the Web Component. Supported languages: en, fr -->
[wp_read_along_web_app_loader version="{version}"]
<read-along href="{text}" audio="{audio}" theme="{theme}" language="en">
---- WP Deployment SNIPPET ----
<!-- wp:html -->
[read_along_web_app_loader version="{version}"]
<read-along href="{wp_upload_folder}{text}" audio="{wp_upload_folder}{audio}" image-assets-folder="{wp_upload_folder}" theme="{theme}" language="eng">
<span slot='read-along-header'>{header}</span>
<span slot='read-along-subheader'>{subheader}</span>
</read-along>
[/wp_read_along_web_app_loader]
[/read_along_web_app_loader]
<!-- /wp:html -->
----- END OF SNIPPET----
"""
Expand All @@ -355,6 +357,9 @@ def save_readme_txt(
subheader,
theme,
):
# setup path for default WordPress upload directory
today = datetime.now()
wp_upload_folder = "/wp-content/uploads/{:%Y/%m}/".format(today)
with open(output_path, "w", encoding="utf-8") as fout:
fout.write(
TEMPLATE_README_TXT.format(
Expand All @@ -364,5 +369,6 @@ def save_readme_txt(
theme=theme,
header=header,
subheader=subheader,
wp_upload_folder=wp_upload_folder,
)
)
Loading

0 comments on commit 469f9ec

Please sign in to comment.