Skip to content

Commit eaefbea

Browse files
committed
draft body images
1 parent 89ed4e1 commit eaefbea

4 files changed

Lines changed: 73 additions & 5 deletions

File tree

‎_content/booklets/footprints-in-the-dust_dhammika.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ external_url: "https://store.pariyatti.org/footprints-in-the-dust"
66
source_url: "https://budblooms.org/2022/04/05/footprints-in-the-dust-the-life-of-the-buddha-from-the-most-ancient-sources/"
77
drive_links:
88
- "https://drive.google.com/file/d/1Fe3n6s3n4BN1GAJd8WUxeJahfh87dJ_3/view?usp=drivesdk"
9+
- "https://drive.google.com/file/d/1VZzvccnqxnjUGunqgDs2aGb-FHiAdpOI/view?usp=drivesdk"
910
course: ebts
1011
status: featured
1112
tags:

‎_includes/big_content_table.html‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@
100100
<script>
101101
const initialwindowwidth = $(window).width();
102102
const mainContentList = new DataTable("#mainContentList", {
103+
// Attempt to fix a scroll jumping bug on mobile
104+
// https://stackoverflow.com/a/38276508
105+
"preDrawCallback": function (settings) {
106+
pageScrollPos = $('div.dataTables_scrollBody').scrollTop();
107+
},
108+
"drawCallback": function (settings) {
109+
$('div.dataTables_scrollBody').scrollTop(pageScrollPos);
110+
},
103111
"order": [], // Save the page order as the default sort
104112
"layout": {
105113
"topStart": {

‎_tags/body.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
title: "The Human Body"
33
status: unpublished
44
parents: [inner]
5+
use_sirv: true
6+
illustration: https://illeakyw.sirv.com/Images/tags/Human_Body_Model.jpg
7+
illustration_height: 683
8+
illustration_width: 1024
9+
illustration_center_x: 30%
10+
illustration_center_y: 25%
11+
illustration_caption: >-
12+
An Italian boy points to the liver of an anatomical model at the Collegio Rotondi
13+
in 2023.
14+
(Photo by <a href="https://commons.wikimedia.org/wiki/File:Human_Body_Model.jpg">Silviaelzi</a>, <a href="https://creativecommons.org/licenses/by/4.0">CC BY 4.0</a>)
15+
image: https://illeakyw.sirv.com/Images/banners/Thai_massage.jpg
16+
image_width: 2304
17+
image_height: 1728
18+
# big_image: https://upload.wikimedia.org/wikipedia/commons/b/b4/Thai_massage.jpg
19+
# big_height: 1728
20+
# big_width: 2304
21+
footer_info: <a href="https://commons.wikimedia.org/wiki/File:Thai_massage.jpg">Ryan Harvey</a>, <a href="https://creativecommons.org/licenses/by-sa/2.0">CC BY-SA 2.0</a>
22+
image_center_x: 90%
23+
image_center_y: 35%
524
---
625

7-
The essential owner's manual.
26+
An owner's manual.

‎scripts/gdrive_copy_folder.py‎

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,17 @@ def copy_folder(source_folder_id: str, dest_parent_id: str = None):
283283
def replace_links_in_doc(docid: str):
284284
doc = gdrive.docs().get(documentId=docid).execute()
285285
print(f"Replacing links in {doc['title']}...")
286-
content = doc['body']['content']
286+
elements = []
287287
requests = []
288-
for block in content:
288+
for block in doc['body']['content']:
289+
for row in block.get('table', {}).get('tableRows', []):
290+
for cell in row.get('tableCells', []):
291+
for cellcontent in cell.get('content', []):
292+
for element in cellcontent.get('paragraph', {}).get('elements', []):
293+
elements.append(element)
289294
for element in block.get('paragraph', {}).get('elements', []):
295+
elements.append(element)
296+
for element in elements:
290297
linkurl = element.get('textRun', {
291298
}).get('textStyle',{
292299
}).get('link',{
@@ -316,8 +323,13 @@ def replace_links_in_doc(docid: str):
316323
print(" Making changes...")
317324
gdrive.docs().batchUpdate(documentId=docid, body={'requests':requests}).execute()
318325

319-
def replace_links_across_all_docs():
320-
for document in gdrive.all_files_matching("mimeType='application/vnd.google-apps.document' and 'me' in owners", "id,name"):
326+
def replace_links_across_all_docs(partialname: str = None):
327+
query = "mimeType='application/vnd.google-apps.document' and 'me' in owners"
328+
if partialname:
329+
query += f" and name contains '{partialname}'"
330+
for document in gdrive.all_files_matching(query, "id,name"):
331+
if partialname not in document['name']:
332+
continue
321333
try:
322334
replace_links_in_doc(document['id'])
323335
except:
@@ -344,6 +356,34 @@ def find_unmigrated_folders():
344356
if folder['trashed']:
345357
print(f"ERROR! Folder {folder['id']} is trashed!")
346358

359+
def update_pkl_filenames():
360+
def new_batch():
361+
return gdrive.BatchHttpRequest(
362+
callback=lambda gid, ret, errror: print(f"Renamed {gid}"),
363+
batch_uri="https://www.googleapis.com/batch/drive/v3"
364+
)
365+
batch = new_batch()
366+
for doc in gdrive.all_files_matching("'1b1dOGh-fmbOhmwoPEnUgDehpqnQhOJ8Z' in parents and trashed=false", "id,name"):
367+
nid = doc['name'][0:-4]
368+
new_id = get_previously_copied_version(nid)
369+
if not new_id:
370+
print(f"...no new name for {doc['name']} (migrated already?)")
371+
else:
372+
batch.add(
373+
request=gdrive.session().files().update(
374+
fileId=doc['id'],
375+
body={
376+
'name': f"{new_id}.{doc['name'].split('.')[-1]}"
377+
}
378+
),
379+
request_id=doc['id']
380+
)
381+
if len(batch._requests) > 49:
382+
batch.execute()
383+
batch = new_batch()
384+
if len(batch._requests) > 0:
385+
batch.execute()
386+
347387
if __name__ == "__main__":
348388
current_user = gdrive.session().about().get(fields='user').execute()['user']
349389
print(f"Currently logged in as \"{current_user['displayName']}\"")

0 commit comments

Comments
 (0)