diff --git a/readalongs/_version.py b/readalongs/_version.py index dfdf142b..98073405 100644 --- a/readalongs/_version.py +++ b/readalongs/_version.py @@ -1 +1 @@ -__version__ = "1.0.20230616" +__version__ = "1.0.20240404" diff --git a/readalongs/align.py b/readalongs/align.py index 3ead0981..51584635 100644 --- a/readalongs/align.py +++ b/readalongs/align.py @@ -47,6 +47,7 @@ parse_time, save_minimal_index_html, save_xml, + save_readme_txt ) MODEL_DIR = os.path.join(os.path.dirname(__file__), "static", "model") @@ -977,7 +978,14 @@ def save_readalong( # Copy the image files to the output's asset directory, if any are found if "images" in config: save_images(config=config, output_dir=output_dir) - + save_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"), + config.get("subheader", ""), + config.get("theme", "light"), + ) def get_word_element(xml: etree.ElementTree, el_id: str) -> etree.ElementTree: """Get the xml etree for a given word by its id""" diff --git a/readalongs/text/util.py b/readalongs/text/util.py index 5a647787..7ebfc260 100644 --- a/readalongs/text/util.py +++ b/readalongs/text/util.py @@ -22,7 +22,7 @@ # too many times, so define it anyway. unicode = str - +CURRENT_WEB_APP_VERSION="1.2.0" def ensure_dirs(path): dirname = os.path.dirname(path) if dirname and not os.path.exists(dirname): @@ -218,7 +218,7 @@ def copy_file_to_zip(zip_path, origin_path, destination_path): - + """ @@ -241,6 +241,7 @@ def save_minimal_index_html( theme=theme, header=header, subheader=subheader, + version=CURRENT_WEB_APP_VERSION, ) ) @@ -295,3 +296,65 @@ def parse_time(time_string: str) -> int: raise ValueError( f'cannot parse "{time_string}" as a valid time in h/m/s/ms' ) from e + +TEMPLATE_README_TXT = """ +Web Deployment Guide + +This folder has everything you need to host your ReadAlong on your own server. + +Your audio ({audio}), (optional) image(s) asset(s), and alignment ({text}) are stored in this folder. + +Your index.html file demonstrates the snippet and imports needed to host the ReadAlong on your server. + +Please host all assets on your server, include the font and package imports defined in the index.html in your website's imports, and include the corresponding snippet everywhere you would like your ReadAlong to be displayed. + + ` + +WordPress Deployment Guide + + +Setup the plugin (do this once) + +Install and activate our plugin 'wp-read-along-web-app-loader' on your WordPress site. + + +Deploy the read-along + +Upload the {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 ---- + + +[wp_read_along_web_app_loader version="{version}"] + + {header} + {subheader} + +[/wp_read_along_web_app_loader] + + ----- END OF SNIPPET---- + +""" +def save_readme_txt( + output_path, + tokenized_xml_basename, + audio_basename, + header, + subheader, + theme, +): + with open(output_path, "w", encoding="utf-8") as fout: + fout.write( + TEMPLATE_README_TXT.format( + version=CURRENT_WEB_APP_VERSION, + text=tokenized_xml_basename, + audio=audio_basename, + theme=theme, + header=header, + subheader=subheader, + ) + ) \ No newline at end of file