Divan-owned content (#30): works edited in Divan take precedence over Wikisource
Some checks failed
Wikisource sync / sync (push) Has been cancelled
Some checks failed
Wikisource sync / sync (push) Has been cancelled
divan/<work url>.dtx (readable source) and .json (generated by the Divan app) override the Wikisource text in the export; such works are marked DivanOwned with who edited them and when. Radif, matla and maqta are computed from Divan's verses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b46fdb5ca9
commit
49f9fe9f38
12
divan/README.md
Normal file
12
divan/README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Divan-owned content
|
||||||
|
|
||||||
|
Works edited or published in Divan, kept here so the daily Wikisource sync never overwrites them
|
||||||
|
(Divan's copy takes precedence; see the divan app, docs/content-model.md).
|
||||||
|
|
||||||
|
- `<work url>.dtx`: the work in Divan text, the readable source (one misra or paragraph per line,
|
||||||
|
so git diffs show exactly what changed). Written by the Divan app when a moderator's change is
|
||||||
|
published.
|
||||||
|
- `<work url>.json`: generated from the `.dtx` by the app: `Title`, `Verses` (the site's verse layout)
|
||||||
|
and `Edited` (who and when). `export_divan.py` uses it in place of the Wikisource text.
|
||||||
|
|
||||||
|
The work url is the site path, e.g. `p266/ghazal/sh7870` for `/p266/ghazal/sh7870`.
|
||||||
@ -118,6 +118,20 @@ def ghazal_marks(v):
|
|||||||
return {**out, "Radif": " ".join(cs[0][1][0].split()[-n:]) if n else "", "Matla": cs[0][0]}
|
return {**out, "Radif": " ".join(cs[0][1][0].split()[-n:]) if n else "", "Matla": cs[0][0]}
|
||||||
|
|
||||||
|
|
||||||
|
# Divan-owned content (#30): works edited in Divan live in divan/ as <work url>.dtx (the readable source,
|
||||||
|
# written by the Divan app) and <work url>.json (generated from it: Title, Verses, Edited). Their text
|
||||||
|
# takes precedence over Wikisource; the Wikisource sync keeps running but never overwrites them.
|
||||||
|
DIVAN_DIR = os.path.join(D, "divan")
|
||||||
|
|
||||||
|
|
||||||
|
def owned(url):
|
||||||
|
path = os.path.join(DIVAN_DIR, url.lstrip("/") + ".json")
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return None
|
||||||
|
with open(path, encoding="utf-8") as f:
|
||||||
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for p in ("poets", "index"):
|
for p in ("poets", "index"):
|
||||||
shutil.rmtree(os.path.join(D, p), ignore_errors=True)
|
shutil.rmtree(os.path.join(D, p), ignore_errors=True)
|
||||||
@ -161,11 +175,18 @@ def main():
|
|||||||
c = cat(path)
|
c = cat(path)
|
||||||
wid = gid("poem", title)
|
wid = gid("poem", title)
|
||||||
shown = ud(title.replace("/", " ۔ "))
|
shown = ud(title.replace("/", " ۔ "))
|
||||||
v, couplets = verses(ud(text), kind == "prose")
|
|
||||||
fmt = "Ghazal" if any("غزل" in s for s in path) else None
|
fmt = "Ghazal" if any("غزل" in s for s in path) else None
|
||||||
purl_ = f"{c['FullUrl']}/sh{wid}"
|
purl_ = f"{c['FullUrl']}/sh{wid}"
|
||||||
|
own = owned(purl_) # Divan's version takes precedence over Wikisource's
|
||||||
|
if own:
|
||||||
|
v = own["Verses"]
|
||||||
|
couplets = len({x["CoupletIndex"] for x in v})
|
||||||
|
shown = own.get("Title") or shown
|
||||||
|
else:
|
||||||
|
v, couplets = verses(ud(text), kind == "prose")
|
||||||
full_title = " » ".join([name, *map(ud, path), shown])
|
full_title = " » ".join([name, *map(ud, path), shown])
|
||||||
write(f"poets{purl_}.json", {
|
write(f"poets{purl_}.json", {
|
||||||
|
**({"DivanOwned": True, "Edited": own.get("Edited")} if own else {}),
|
||||||
"Id": wid, "CatId": c["Id"], "Title": shown, "FullTitle": full_title, "FullUrl": purl_,
|
"Id": wid, "CatId": c["Id"], "Title": shown, "FullTitle": full_title, "FullUrl": purl_,
|
||||||
"RhymeLetters": None, "SourceName": "ویکی ماخذ", "SourceUrlSlug": "wikisource", "SourceUrl": url,
|
"RhymeLetters": None, "SourceName": "ویکی ماخذ", "SourceUrlSlug": "wikisource", "SourceUrl": url,
|
||||||
"Language": "ur-PK", "PoemSummary": None, "Metre": None,
|
"Language": "ur-PK", "PoemSummary": None, "Metre": None,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user