summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-11-17 19:25:41 +0100
committerJules Laplace <julescarbon@gmail.com>2020-11-17 19:25:41 +0100
commit0e57e3f23723bfe4a951297511656c573bb57578 (patch)
tree64cf0189f183eb03d0b7eff3095ccef02b3e7ffd
parent83aab124546ef6753b3c4674a43978ccece44e33 (diff)
auto ftp deploy
-rw-r--r--animism-align/cli/commands/site/export.py67
1 files changed, 65 insertions, 2 deletions
diff --git a/animism-align/cli/commands/site/export.py b/animism-align/cli/commands/site/export.py
index 5abc04c..1582a2b 100644
--- a/animism-align/cli/commands/site/export.py
+++ b/animism-align/cli/commands/site/export.py
@@ -29,7 +29,8 @@ def cli(ctx, opt_output_dir):
page_title = "Animism: Episode 1"
page_name = "episode1"
page_desc = "A Report on Migrating Souls in Museums and Moving Pictures"
- page_image = ""
+ page_image = "http://animism.e-flux.com/episode1/media/8ca4adc754093cc8578a3033de8f96af96180fbce838c480636ffd5d128d1937.jpg"
+ site_url = "https://animism.e-flux.com/" + page_name
page_url = "/" + page_name
media_url = "/" + page_name + "/media"
@@ -55,6 +56,18 @@ def cli(ctx, opt_output_dir):
}
# ------------------------------------------------
+ # build the json for the e-flux search
+
+ search_json = [{
+ "text": transcript_to_text(db),
+ "url": site_url,
+ "type": "text",
+ "previewtitle": '<i>Animism</i>, episode 1',
+ "previewtext": page_desc,
+ "previewimage": page_image,
+ }]
+
+ # ------------------------------------------------
# build the index.html
index_html = load_text(join(app_cfg.DIR_STATIC, 'site.html'), split=False)
@@ -68,9 +81,10 @@ def cli(ctx, opt_output_dir):
write_text(index_html, join(site_fp_out, 'index.html'))
# ------------------------------------------------
- # build the index.json
+ # write all the json
write_json(db, join(site_fp_out, 'index.json'), default=str, minify=False)
+ write_json(search_json, join(site_fp_out, 'search.json'), default=str, minify=False)
# ------------------------------------------------
# write custom css
@@ -99,6 +113,15 @@ def cli(ctx, opt_output_dir):
os.chdir(app_cfg.DIR_PROJECT_ROOT)
os.system(f'NODE_ENV=production node ./node_modules/webpack-cli/bin/cli.js --config ./webpack.config.site.js -o {site_fp_out}/bundle.js')
+ print("Deploying site...")
+ os.system("""
+ lftp -c "set ssl:verify-certificate false; set ftp:list-options -a;
+ open ftp://animism:Agkp8#48@93.114.86.205;
+ lcd ./data_store/exports/animism;
+ cd /;
+ mirror --reverse --use-cache --verbose --no-umask --ignore-time --parallel=2"
+ """)
+
print("Site export complete!")
print(f"Site exported to: {site_fp_out}")
@@ -250,6 +273,46 @@ def db_get(db, table, idx):
return db[table]['lookup'][id]
######################################################################
+# Plaintext helper functions
+######################################################################
+
+def transcript_to_text(db):
+ s = ""
+ para = ""
+ last_pid = 0
+ section_count = 0
+ notes = []
+ # check each annotation
+ for a in IterateTable(db['annotation']):
+ # skip media annotations (for now..)
+ if a['type'] not in app_cfg.TEXT_ANNOTATION_TYPES:
+ continue
+ # if it's a section heading or the paragraph id changed, append
+ # print(f"{a['type']} {a['paragraph_id']}")
+ if a['type'] == 'section_heading' or a['paragraph_id'] != last_pid:
+ if len(para):
+ s += para + "\n\n"
+ para = ""
+ last_pid = a['paragraph_id']
+ # if it's a new section, add a heading
+ if a['type'] == 'section_heading':
+ s += f"{app_cfg.ROMAN_NUMERALS[section_count]}: {a['text']}\n"
+ section_count += 1
+ last_pid = a['paragraph_id']
+ # elif a['type'] == 'footnote':
+ # para += f"<sup>{len(notes)+1}</sup> "
+ # notes.append(a['text'])
+ else:
+ para += a['text'] + " "
+ if len(para):
+ s += para
+ # if len(notes):
+ # s += h(3, "Footnotes")
+ # for i, note in enumerate(notes):
+ # s += p(f"<sup>{i+1}</sup> " + note)
+ return s
+
+######################################################################
# HTML Helper Functions
######################################################################