Compare commits
4 Commits
e944129627
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 870dd695b0 | |||
| aa867adc18 | |||
| 2e2da08a09 | |||
| 5ed1a6ebd7 |
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
conf.yml
|
conf.yml
|
||||||
public/
|
public/
|
||||||
content/events
|
content/events/
|
||||||
content/bibliography
|
content/bibliography/
|
||||||
|
|
||||||
# ---> macOS
|
# ---> macOS
|
||||||
# General
|
# General
|
||||||
|
|||||||
@@ -2,9 +2,22 @@
|
|||||||
|
|
||||||
Site logics of "Mathematics & Artifice"
|
Site logics of "Mathematics & Artifice"
|
||||||
|
|
||||||
'''
|
Setup:
|
||||||
|
```
|
||||||
> python -m venv venv
|
> python -m venv venv
|
||||||
> source venv/bin/activate
|
> source venv/bin/activate
|
||||||
> pip install -r requirements.txt
|
> pip install -r requirements.txt
|
||||||
> python make.py
|
> python make.py
|
||||||
'''
|
```
|
||||||
|
|
||||||
|
Fetch bibliography (make sure conf.yml is set/valid):
|
||||||
|
```
|
||||||
|
> python fetch_bib.py
|
||||||
|
> python make.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Fetch events (make sure conf.yml is set/valid):
|
||||||
|
```
|
||||||
|
> python fetch_ics.py
|
||||||
|
> python make.py
|
||||||
|
```
|
||||||
|
|||||||
+8
-1
@@ -1,4 +1,4 @@
|
|||||||
import pathlib, re, frontmatter, markdown, citeproc, json
|
import argparse, pathlib, re, frontmatter, markdown, citeproc, json
|
||||||
from pyzotero import zotero
|
from pyzotero import zotero
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
import utils
|
import utils
|
||||||
@@ -66,6 +66,10 @@ def format_filename_title(data_csl:dict, bib_entry:str):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
p = argparse.ArgumentParser(description="Fetch zotero bibliography")
|
||||||
|
p.add_argument("--interactive", default=False, action=argparse.BooleanOptionalAction, help="make interactive")
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
conf = utils.load_conf()
|
conf = utils.load_conf()
|
||||||
|
|
||||||
z = zotero.Zotero(conf['zotero_group_id'], conf['zotero_lib_type'], conf['zotero_api_key'])
|
z = zotero.Zotero(conf['zotero_group_id'], conf['zotero_lib_type'], conf['zotero_api_key'])
|
||||||
@@ -125,8 +129,11 @@ if __name__ == "__main__":
|
|||||||
## selective update
|
## selective update
|
||||||
new = format_reading(title=title, desc=bib_entry)
|
new = format_reading(title=title, desc=bib_entry)
|
||||||
|
|
||||||
|
if(args.interactive):
|
||||||
updated = update_reading(prev, new)
|
updated = update_reading(prev, new)
|
||||||
utils.save_file(filepath, frontmatter.dumps(updated), overwrite=True)
|
utils.save_file(filepath, frontmatter.dumps(updated), overwrite=True)
|
||||||
|
else:
|
||||||
|
utils.save_file(filepath, frontmatter.dumps(new), overwrite=True)
|
||||||
|
|
||||||
print(f"reading {e} updated")
|
print(f"reading {e} updated")
|
||||||
|
|
||||||
|
|||||||
+13
-5
@@ -1,4 +1,4 @@
|
|||||||
import pathlib, ics, requests, arrow, frontmatter
|
import argparse, pathlib, ics, requests, arrow, frontmatter
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
DFMT = "YYYY-MM-DD"
|
DFMT = "YYYY-MM-DD"
|
||||||
@@ -22,8 +22,8 @@ def format_event(title:str, date:str, location:str, desc:str):
|
|||||||
def compare_events(path:pathlib.PosixPath, title:str, date:str, location:str, desc:str):
|
def compare_events(path:pathlib.PosixPath, title:str, date:str, location:str, desc:str):
|
||||||
p = frontmatter.load(path)
|
p = frontmatter.load(path)
|
||||||
pd = p.to_dict()
|
pd = p.to_dict()
|
||||||
pd['content'] = pd['content'].strip()
|
pd['content'] = pd['content'].strip() if pd['content'] else ''
|
||||||
return p, (pd == {'title': title, 'date': date, 'location': location, 'type': 'event', 'content': desc.strip()})
|
return p, (pd == {'title': title, 'date': date, 'location': location, 'type': 'event', 'content': desc.strip() if desc else ''})
|
||||||
|
|
||||||
def update_event(previous:frontmatter.Post, new:frontmatter.Post):
|
def update_event(previous:frontmatter.Post, new:frontmatter.Post):
|
||||||
keys = set(previous.keys()).union(set(new.keys()))
|
keys = set(previous.keys()).union(set(new.keys()))
|
||||||
@@ -50,6 +50,10 @@ def read_date(p:frontmatter.Post):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
p = argparse.ArgumentParser(description="Fetch ICS calendar")
|
||||||
|
p.add_argument("--interactive", default=False, action=argparse.BooleanOptionalAction, help="make interactive")
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
conf = utils.load_conf()
|
conf = utils.load_conf()
|
||||||
|
|
||||||
req = requests.get(conf['ics_url']).text
|
req = requests.get(conf['ics_url']).text
|
||||||
@@ -61,8 +65,9 @@ if __name__ == "__main__":
|
|||||||
name = e.name.replace(' ', '-')
|
name = e.name.replace(' ', '-')
|
||||||
fm_date = e.begin.format(DFMT)
|
fm_date = e.begin.format(DFMT)
|
||||||
fm_date_interval = f"{e.begin.format(DHFMT)}-{e.end.format(HFMT)}"
|
fm_date_interval = f"{e.begin.format(DHFMT)}-{e.end.format(HFMT)}"
|
||||||
filename = f'{fm_date}-{name}.md'
|
# filename = f'{fm_date}-{name}.md'
|
||||||
filepath = pathlib.Path(conf['content']) / 'event' / filename
|
filename = e.uid + '.md'
|
||||||
|
filepath = pathlib.Path(conf['content']) / 'events' / filename
|
||||||
|
|
||||||
if not filepath.exists():
|
if not filepath.exists():
|
||||||
print(f"new event: {e.name}")
|
print(f"new event: {e.name}")
|
||||||
@@ -80,8 +85,11 @@ if __name__ == "__main__":
|
|||||||
## selective update
|
## selective update
|
||||||
new = format_event(title=e.name, date=fm_date_interval, location=e.location, desc=e.description)
|
new = format_event(title=e.name, date=fm_date_interval, location=e.location, desc=e.description)
|
||||||
|
|
||||||
|
if(args.interactive):
|
||||||
updated = update_event(prev, new)
|
updated = update_event(prev, new)
|
||||||
utils.save_file(filepath, frontmatter.dumps(updated), overwrite=True)
|
utils.save_file(filepath, frontmatter.dumps(updated), overwrite=True)
|
||||||
|
else:
|
||||||
|
utils.save_file(filepath, frontmatter.dumps(new), overwrite=True)
|
||||||
|
|
||||||
print(f"event {e.name} updated")
|
print(f"event {e.name} updated")
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ if __name__ == "__main__":
|
|||||||
if not events_dir.exists():
|
if not events_dir.exists():
|
||||||
print("path content/events does not exist.")
|
print("path content/events does not exist.")
|
||||||
else:
|
else:
|
||||||
events = list(utils.get_files_in_subdir(conf['content'], 'event', 'md').values())
|
events = list(utils.get_files_in_subdir(conf['content'], 'events', 'md').values())
|
||||||
for e in events:
|
for e in events:
|
||||||
p = frontmatter.load(e)
|
p = frontmatter.load(e)
|
||||||
summary = f"{p['title']} - {p['date']}"
|
summary = f"{p['title']} - {p['date']}"
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if ! [[ "$1" =~ ^(install|bib|cal|output|all|clean) ]]; then
|
||||||
|
echo "usage: $0 [action]"
|
||||||
|
echo "where action can be: [install|bib|cal|output|all|clean]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
|
||||||
|
install)
|
||||||
|
echo "intalling virtual environment"
|
||||||
|
python -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
echo "make sure to edit the config file conf.edit-me.yml"
|
||||||
|
;;
|
||||||
|
bib)
|
||||||
|
echo "fetching bibliography"
|
||||||
|
python fetch_bib.py
|
||||||
|
;;
|
||||||
|
cal)
|
||||||
|
echo "fetching calendar"
|
||||||
|
python fetch_ics.py
|
||||||
|
;;
|
||||||
|
output)
|
||||||
|
echo "creating output"
|
||||||
|
python make.py
|
||||||
|
;;
|
||||||
|
all)
|
||||||
|
echo "fetching calendar + bibliography + creating output"
|
||||||
|
python fetch_bib.py
|
||||||
|
python fetch_ics.py
|
||||||
|
python make.py
|
||||||
|
;;
|
||||||
|
clean)
|
||||||
|
echo "cleaning virtual environment"
|
||||||
|
rm -rf venv
|
||||||
|
rm -rf __pycache__
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
@@ -3,10 +3,12 @@ attrs==24.2.0
|
|||||||
bibtexparser==1.4.2
|
bibtexparser==1.4.2
|
||||||
certifi==2024.8.30
|
certifi==2024.8.30
|
||||||
charset-normalizer==3.3.2
|
charset-normalizer==3.3.2
|
||||||
|
citeproc-py==0.6.0
|
||||||
feedparser==6.0.11
|
feedparser==6.0.11
|
||||||
ics==0.7.2
|
ics==0.7.2
|
||||||
idna==3.10
|
idna==3.10
|
||||||
Jinja2==3.1.4
|
Jinja2==3.1.4
|
||||||
|
lxml==5.3.0
|
||||||
Markdown==3.7
|
Markdown==3.7
|
||||||
MarkupSafe==2.1.5
|
MarkupSafe==2.1.5
|
||||||
pyparsing==3.1.4
|
pyparsing==3.1.4
|
||||||
|
|||||||
Reference in New Issue
Block a user