Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deploy librelingo tools output to github pages #1946

Merged
merged 3 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_args():
def generate_html(start_time, end_time, links, outdir):
root = os.path.dirname(os.path.abspath(__file__))
templates_dir = os.path.join(root, "templates")
env = Environment(loader=FileSystemLoader(templates_dir))
env = Environment(loader=FileSystemLoader(templates_dir), autoescape=True)
template = env.get_template("courses.html")
html = template.render(start_time=start_time, end_time=end_time, links=links)

Expand Down Expand Up @@ -51,7 +51,10 @@ def generate_course(sdir, outdir, tdir, course_dir):
python = sys.executable
cmd = f"{python} {lilipy} --course {course_dir} --html {docs_dir}"
print(cmd)
success = os.system(cmd) == 0
success = (
os.system(cmd) == 0
) # replace this arbitrary system call with a simple Python call
# {or refactor this file as a shell script. But Python code is preferable)
os.chdir(current_dir)
with open(os.path.join(docs_dir, "course.json")) as fh:
count = json.load(fh)
Expand Down Expand Up @@ -100,7 +103,7 @@ def main():
tdir = "basque-from-english"
links.append(
generate_course(
sdir="LibreLingo",
sdir=".",
outdir=outdir,
tdir=tdir,
course_dir=f"courses/{tdir}",
Expand All @@ -109,12 +112,12 @@ def main():
with open(os.path.join(outdir, tdir, "course.json")) as fh:
courses_data[tdir] = json.load(fh)

for tdir in os.listdir("LibreLingo/temporarily_inactive_courses/"):
for tdir in os.listdir("./temporarily_inactive_courses/"):
if tdir == "basque-from-english":
continue
links.append(
generate_course(
sdir="LibreLingo",
sdir=".",
outdir=outdir,
tdir=tdir,
course_dir=f"temporarily_inactive_courses/{tdir}",
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/tools/lili.py → apps/tools/librelingo_tools/lili.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def guess_path_to_course(path_to_course):
def render(template_file, **args):
root = os.path.dirname(os.path.abspath(__file__))
templates_dir = os.path.join(root, "templates")
env = Environment(loader=FileSystemLoader(templates_dir))
env = Environment(loader=FileSystemLoader(templates_dir), autoescape=True)
template = env.get_template(template_file)
html = template.render(**args)
return html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div id="output">
<div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
var source_to_target = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Missing Words</h2>
</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
//var source_to_target = null;
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion apps/tools/practice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import argparse
import random

from lili import guess_path_to_course, collect_data, collect_words, collect_phrases
from librelingo_tools.lili import ( # type: ignore
guess_path_to_course,
collect_data,
collect_words,
collect_phrases,
)
from librelingo_yaml_loader.yaml_loader import load_course


Expand Down
2 changes: 1 addition & 1 deletion apps/tools/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.poetry]
name = "tools"
name = "librelingo-tools"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Skill:
Id: 212
Name: Because 2-2
Id: 213
Name: Because 2-3
Thumbnails:

New words:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"export:production": "yarn web installAllExternalCourses && yarn exportAllCourses && yarn web export && yarn docs:build && mv ./apps/web/__sapper__/ .",
"export": "yarn web export && mv ./apps/web/__sapper__/ .",
"export": "yarn web export && mv ./apps/web/__sapper__/ . && poetry run python apps/tools/librelingo_tools/generate.py --courses ./config/courses.json --outdir ./__sapper__/export/course-tools-legacy",
"deploy": "echo 'librelingo.app' > __sapper__/export/CNAME && gh-pages -d __sapper__/export",
"commit": "git-cz",
"test": "jest",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ librelingo-fakes = { path = "./apps/librelingo_fakes", develop = true }
librelingo-utils = { path = "./apps/librelingo_utils", develop = true }
librelingo-audios = { path = "./apps/librelingo_audios", develop = true }
librelingo-types = { path = "./apps/librelingo_types", develop = true }
librelingo-tools = { path = "./apps/tools", develop = true }
pytest = "^6.2.2"
pytest-mock = "^3.5.1"
pytest-watch = "^4.2.0"
Expand Down