Compare commits
77 Commits
3b042b718f
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b030b24f4 | |||
| 44b651cace | |||
| eb2edc3710 | |||
| f63497090b | |||
| 215142dee4 | |||
| e391f64cc5 | |||
| 4216d153fd | |||
| 9241ecfee8 | |||
| 4bc7a6d980 | |||
| b50833f19f | |||
| f5cccc30dc | |||
| 8a8f02c5bd | |||
| 292d71edc5 | |||
| c9fb8fda93 | |||
| 1fae03e70b | |||
| 6ed94db8cf | |||
| 02a7c29dba | |||
| cf8e2955c2 | |||
| 7aa06b7f83 | |||
| f7a690405b | |||
| 93ea11cd0e | |||
| 263281df3c | |||
|
|
b953933e6f | ||
| 7db84492b5 | |||
| c7cd5e0601 | |||
| c05f8fad35 | |||
| b9c7535812 | |||
| cdcd3bce1f | |||
| 6eb02cc95f | |||
| 2454d26d6b | |||
| 8054a4a983 | |||
| afefce0a11 | |||
| 334c82d098 | |||
| ddd536c958 | |||
| ae5ba0d044 | |||
| 83133218a4 | |||
| d412d983bd | |||
| 9859229101 | |||
| dc8f9d91e7 | |||
| f3a86b8070 | |||
| b814434c48 | |||
| ba05ecdd94 | |||
| 1751158cbd | |||
| c45cebe497 | |||
| dc61a7ee92 | |||
| d70a0a8630 | |||
| 4f37283e68 | |||
| 0e948e7f55 | |||
| 79c95a9ddb | |||
| 0ca0fb90d6 | |||
| 603a7f5942 | |||
| 63f8541a82 | |||
| dc5af8da28 | |||
| 3fdbf13d95 | |||
| 7e4640e7d9 | |||
|
|
8239b3ea6d | ||
|
|
3f0049dfdb | ||
|
|
a113a13318 | ||
| 3926277f8f | |||
| 69b3efd78f | |||
| 2b80c90a19 | |||
| 37d28a3542 | |||
| 3e692dd74f | |||
| 3e6884ad8a | |||
| 8e57af5a78 | |||
| 37974c418b | |||
| 2dc1dfef98 | |||
| c36deab71a | |||
| 432f16ba08 | |||
| ee26af8b35 | |||
|
|
523402d3ad | ||
| d2d2628e56 | |||
| 7a3aec9872 | |||
| bfa9cb1527 | |||
| 4b307d7896 | |||
| b1a4d8e6ae | |||
| fa512cfb0e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -173,4 +173,5 @@ cython_debug/
|
|||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
|
|
||||||
dist
|
dist
|
||||||
|
context.json
|
||||||
@@ -2,7 +2,10 @@
|
|||||||
name = "stsg"
|
name = "stsg"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"watchdog~=6.0.0",
|
"watchdog~=6.0.0",
|
||||||
"markdown~=3.3.6"
|
"markdown~=3.3.6",
|
||||||
|
"bs4~=0.0.2",
|
||||||
|
"toml~0.10.2",
|
||||||
|
"jinja2~=3.1.6",
|
||||||
]
|
]
|
||||||
dynamic = []
|
dynamic = []
|
||||||
authors = []
|
authors = []
|
||||||
|
|||||||
75
src/articles/en.md
Normal file
75
src/articles/en.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Populumque avidosque Sparte quoque auctore equidem
|
||||||
|
|
||||||
|
## Sunt aevis
|
||||||
|
|
||||||
|
Lorem markdownum turbavere prisca Aeacidae morando esse. Quam Styga spectata,
|
||||||
|
pariter Iove iunctis exercere Solis? Atlantis possit succurrere quam!
|
||||||
|
|
||||||
|
if (stationRecord < ctp(rup, columnBase, dtd)) {
|
||||||
|
impact_qbe_symbolic(bank_c(exploit_gnutella_social), inbox);
|
||||||
|
marketing = telnetWebmasterFpu;
|
||||||
|
circuitSoapDns(dac, ieee);
|
||||||
|
} else {
|
||||||
|
ebook.spider(wildcard_publishing_memory.tcpDisk(encoding, 48149), -1 +
|
||||||
|
copyright_flash_icmp, superscalar_cluster + kofficeIsp);
|
||||||
|
reimage.mac = dslWebmail;
|
||||||
|
kilobyteVariable.margin_keylogger = dvd + microcomputer;
|
||||||
|
}
|
||||||
|
font_switch(servlet, file(1, protocol) * skinTouchscreen,
|
||||||
|
wheel_station_computer);
|
||||||
|
var startRom = bit(php_touchscreen_icio);
|
||||||
|
var unicode_hover_tiger = command(scan_install_cd(ruby(mail_chipset, web,
|
||||||
|
clientMemeSoftware), optical, wirelessMegahertz), oasis);
|
||||||
|
|
||||||
|
## Est nec locumque anxia et
|
||||||
|
|
||||||
|
Maligno puppes potuit petit. **Ipse regnat venit** tangit mitti opibus est unus
|
||||||
|
spectacula erat! Bacche qui dedit in ardet Phrygiis Liternum ipso ille Orphei
|
||||||
|
Canentem *ut*, parenti terrae! Frondibus deus sine leoni frustraque lentus. Est
|
||||||
|
deos cum corripuit erat sibi concussit simul; suus tantum.
|
||||||
|
|
||||||
|
Camenis Lucifer ex geniti sitis quem. Styga si Ceae nova media remugis: haerens
|
||||||
|
ridet, nam [Pindo](http://www.murra.com/argolicaemaximus) est tritis flamma
|
||||||
|
[dixit una licebit](http://www.sedare-mopsus.net/) Pelia perdite! Aura *aurea
|
||||||
|
mecum* una mirabantur mansit domum simul de Euboica altis vincula tenentis vires
|
||||||
|
sub, *Scythicae*. Mora sitis pocula. Ultimus idem triplices inquit.
|
||||||
|
|
||||||
|
## Et atque ministris imagine fas tenuit fornacibus
|
||||||
|
|
||||||
|
Adeunda suffundit ille: Bacchi moribundo et quam **cacumina videre Tamasenum**.
|
||||||
|
Gauderet in [non arbitrium caelo](http://www.madidusperiuraque.io/).
|
||||||
|
|
||||||
|
## In corpora in micat Phoebus corque transitus
|
||||||
|
|
||||||
|
Mihi in macies, ab avoque malorum decusque. Appellant expellam unus colore
|
||||||
|
exiguo, maior ara loqui sit vires.
|
||||||
|
|
||||||
|
var uat = cardPrinterLocalhost.pppoe(display, operating_row_fsb(
|
||||||
|
scalable_lion, compilerHeuristicTweet - 22));
|
||||||
|
var toslink_software = tokenPciPrompt.source_x_firmware(drive,
|
||||||
|
boxSdkDlc.servicesIcsDrive(certificate_cycle_illegal(resolution)),
|
||||||
|
outboxTftMap + rssTextZebibyte.flashImpactDisk(3, eup_ad));
|
||||||
|
var compression = programWebPort;
|
||||||
|
if (intellectual_left_system) {
|
||||||
|
favorites(lossyDramDay + 7, upsSliTruncate, 2);
|
||||||
|
laptop.android = ocr_piracy(clean, flatbedRte - -1);
|
||||||
|
directx_file_cable = -1;
|
||||||
|
} else {
|
||||||
|
point_sink_controller(flash(filenameDataAccess, vleSoftwareListserv),
|
||||||
|
point_rate_cmos(control_soa_restore));
|
||||||
|
javascript *= nic_format;
|
||||||
|
address = nameDcim(touchscreenLink.port_port(diskHeat, vaporware));
|
||||||
|
}
|
||||||
|
|
||||||
|
## Enim nunc solvi
|
||||||
|
|
||||||
|
Est pudet citharae, corpus? Modo in armentaque pennisque videri aquarum, est
|
||||||
|
equos ne in vulnere domus; maris. Quodque quoque orbe omnes metus, sol
|
||||||
|
[putas](http://www.uno.com/deorumvolumine) marmore fuit secreta haut vobis,
|
||||||
|
faciendo, oro.
|
||||||
|
|
||||||
|
Quid sequenti, supersunt quoque, sortite; in in tenetur vecta horriferamque
|
||||||
|
amabat. Vos nudae anni amor chelydri [Picus candentibus
|
||||||
|
et](http://pugnare.io/angulus.html) sonum, et sentibus geminato volucrem
|
||||||
|
mercibus bracchia, cum *posito* delubraque. Templa extrahit in totidem altera
|
||||||
|
Nioben, honoris sui, fibris!
|
||||||
57
src/articles/example/de-DE.md
Normal file
57
src/articles/example/de-DE.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
meow
|
||||||
|
|
||||||
|
# Abstrahere reddita celebrare in ossa
|
||||||
|
|
||||||
|
## Usque de celebrabant puer
|
||||||
|
|
||||||
|
Lorem markdownum, nec ora et vero me nec natae suadent. Nec damno ignorat
|
||||||
|
propiore aliquid temptata decipienda habetur. Vulnera lacrimis aequoreo madidos,
|
||||||
|
copia uvae, herbosaque quoque, per harenas, canos fui monstro Peleus.
|
||||||
|
|
||||||
|
Et fuge cum liquidum puer Herculis arentis, tantum caudaque et generi vilior, in
|
||||||
|
rubore. Caeli modo palmis, suo tria accipe visus non similis qui remittat
|
||||||
|
retentus porrigit fluxit ubi testis.
|
||||||
|
|
||||||
|
> Sulphura et color reliquit dextera: quid summa continuere obductos egesto
|
||||||
|
> moriens **fluentia vult iunctamque**, mihi patres spiro. Est Iovis **imperat
|
||||||
|
> quem est** putavi annis *omnis*; flumina, leporem constabat grave pelagi,
|
||||||
|
> insiluit, igne invito? Auctor circuit quod.
|
||||||
|
|
||||||
|
## Rhoetus gravis
|
||||||
|
|
||||||
|
Parari modo in sustulerat: ora sic verba meruit, uti. Pignora citus facto
|
||||||
|
amplectimur cupido amentes foedantem multoque datura.
|
||||||
|
[Quid](http://www.prima.net/se) ex tanti armaque exhibita descenderat!
|
||||||
|
|
||||||
|
1. Alis ima
|
||||||
|
2. Mirantur nive sit
|
||||||
|
3. Maris ut adlabimur humana fine quam vultusque
|
||||||
|
|
||||||
|
## A idonea miserum
|
||||||
|
|
||||||
|
Montes tibi deorum igitur. Poterat nunc porrigitur perdidimus *sidereos animi
|
||||||
|
praesepia* nihil praeferri functa, in **Pleias removete** oculos sollemni
|
||||||
|
Tatius: **modo**. Inde dedit! Atque in matrem spinae foret ponti quam dixit,
|
||||||
|
aras. Gladii addendum fiducia magno, se quo fata humo esse **tellure corpora
|
||||||
|
discederet** sucis manibus, parentem ante, Iovem.
|
||||||
|
|
||||||
|
Laqueique honore sequentia tyranni Harpalos, paelex, foedat tempestiva nomen.
|
||||||
|
Sit ter indiciumque requirit utrumque in nil et *suspectus*, quaerite patriam
|
||||||
|
nec facta [securi](http://heuqua.io/adhaut). Confessa ut per sit nostro futura
|
||||||
|
metaque oblitae fameque exit adspiciens. Morte flectere invidiam certe cum
|
||||||
|
vixque *nubes clamor viderunt* praeceps infamis collo percussis axem plena saxum
|
||||||
|
urbes ferre undae. Totoque utuntur ore lupus inplet sibila ullam, qui corpore
|
||||||
|
*contermina aera*?
|
||||||
|
|
||||||
|
Convocat ipse abeunt sententia concolor a Auguste epops solent iubet qui
|
||||||
|
aequora. In illi, solvente resecare violentam nescio accipit multarum [aureus
|
||||||
|
exspectatus](http://oris-tibi.io/nasci) ergo ora. Positis **inquit**, sit iamque
|
||||||
|
hederae ulterius, pontus linguae matutina terra sic isse Graium passosque
|
||||||
|
sanguinis secus petit!
|
||||||
|
|
||||||
|
Adfore dei volucrum Lydas; [hoc](http://similemnescitve.net/ipsamquee) quam
|
||||||
|
[superosque](http://www.quoqueabit.com/cumqueiam.html) caligine vulnera quoque
|
||||||
|
corpus foedaque mentis qui nectare, fatendo sensit! Rursus nulli miraris nuda
|
||||||
|
*Acrisio*. Cum modo, satis dissuadet luce; cum *freta* ab et diu, labor *tenuata
|
||||||
|
ieiunia*? Caesosque thalamique precor, dedit nulla loca [arce
|
||||||
|
et](http://viscera-rerum.com/mixta) tinguit aera.
|
||||||
75
src/articles/example/en.md
Normal file
75
src/articles/example/en.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Populumque avidosque Sparte quoque auctore equidem
|
||||||
|
|
||||||
|
## Sunt aevis
|
||||||
|
|
||||||
|
Lorem markdownum turbavere prisca Aeacidae morando esse. Quam Styga spectata,
|
||||||
|
pariter Iove iunctis exercere Solis? Atlantis possit succurrere quam!
|
||||||
|
|
||||||
|
if (stationRecord < ctp(rup, columnBase, dtd)) {
|
||||||
|
impact_qbe_symbolic(bank_c(exploit_gnutella_social), inbox);
|
||||||
|
marketing = telnetWebmasterFpu;
|
||||||
|
circuitSoapDns(dac, ieee);
|
||||||
|
} else {
|
||||||
|
ebook.spider(wildcard_publishing_memory.tcpDisk(encoding, 48149), -1 +
|
||||||
|
copyright_flash_icmp, superscalar_cluster + kofficeIsp);
|
||||||
|
reimage.mac = dslWebmail;
|
||||||
|
kilobyteVariable.margin_keylogger = dvd + microcomputer;
|
||||||
|
}
|
||||||
|
font_switch(servlet, file(1, protocol) * skinTouchscreen,
|
||||||
|
wheel_station_computer);
|
||||||
|
var startRom = bit(php_touchscreen_icio);
|
||||||
|
var unicode_hover_tiger = command(scan_install_cd(ruby(mail_chipset, web,
|
||||||
|
clientMemeSoftware), optical, wirelessMegahertz), oasis);
|
||||||
|
|
||||||
|
## Est nec locumque anxia et
|
||||||
|
|
||||||
|
Maligno puppes potuit petit. **Ipse regnat venit** tangit mitti opibus est unus
|
||||||
|
spectacula erat! Bacche qui dedit in ardet Phrygiis Liternum ipso ille Orphei
|
||||||
|
Canentem *ut*, parenti terrae! Frondibus deus sine leoni frustraque lentus. Est
|
||||||
|
deos cum corripuit erat sibi concussit simul; suus tantum.
|
||||||
|
|
||||||
|
Camenis Lucifer ex geniti sitis quem. Styga si Ceae nova media remugis: haerens
|
||||||
|
ridet, nam [Pindo](http://www.murra.com/argolicaemaximus) est tritis flamma
|
||||||
|
[dixit una licebit](http://www.sedare-mopsus.net/) Pelia perdite! Aura *aurea
|
||||||
|
mecum* una mirabantur mansit domum simul de Euboica altis vincula tenentis vires
|
||||||
|
sub, *Scythicae*. Mora sitis pocula. Ultimus idem triplices inquit.
|
||||||
|
|
||||||
|
## Et atque ministris imagine fas tenuit fornacibus
|
||||||
|
|
||||||
|
Adeunda suffundit ille: Bacchi moribundo et quam **cacumina videre Tamasenum**.
|
||||||
|
Gauderet in [non arbitrium caelo](http://www.madidusperiuraque.io/).
|
||||||
|
|
||||||
|
## In corpora in micat Phoebus corque transitus
|
||||||
|
|
||||||
|
Mihi in macies, ab avoque malorum decusque. Appellant expellam unus colore
|
||||||
|
exiguo, maior ara loqui sit vires.
|
||||||
|
|
||||||
|
var uat = cardPrinterLocalhost.pppoe(display, operating_row_fsb(
|
||||||
|
scalable_lion, compilerHeuristicTweet - 22));
|
||||||
|
var toslink_software = tokenPciPrompt.source_x_firmware(drive,
|
||||||
|
boxSdkDlc.servicesIcsDrive(certificate_cycle_illegal(resolution)),
|
||||||
|
outboxTftMap + rssTextZebibyte.flashImpactDisk(3, eup_ad));
|
||||||
|
var compression = programWebPort;
|
||||||
|
if (intellectual_left_system) {
|
||||||
|
favorites(lossyDramDay + 7, upsSliTruncate, 2);
|
||||||
|
laptop.android = ocr_piracy(clean, flatbedRte - -1);
|
||||||
|
directx_file_cable = -1;
|
||||||
|
} else {
|
||||||
|
point_sink_controller(flash(filenameDataAccess, vleSoftwareListserv),
|
||||||
|
point_rate_cmos(control_soa_restore));
|
||||||
|
javascript *= nic_format;
|
||||||
|
address = nameDcim(touchscreenLink.port_port(diskHeat, vaporware));
|
||||||
|
}
|
||||||
|
|
||||||
|
## Enim nunc solvi
|
||||||
|
|
||||||
|
Est pudet citharae, corpus? Modo in armentaque pennisque videri aquarum, est
|
||||||
|
equos ne in vulnere domus; maris. Quodque quoque orbe omnes metus, sol
|
||||||
|
[putas](http://www.uno.com/deorumvolumine) marmore fuit secreta haut vobis,
|
||||||
|
faciendo, oro.
|
||||||
|
|
||||||
|
Quid sequenti, supersunt quoque, sortite; in in tenetur vecta horriferamque
|
||||||
|
amabat. Vos nudae anni amor chelydri [Picus candentibus
|
||||||
|
et](http://pugnare.io/angulus.html) sonum, et sentibus geminato volucrem
|
||||||
|
mercibus bracchia, cum *posito* delubraque. Templa extrahit in totidem altera
|
||||||
|
Nioben, honoris sui, fibris!
|
||||||
35
src/articles/example/ku.md
Normal file
35
src/articles/example/ku.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Navê Gotarê example
|
||||||
|
Ev gotar, mînakek placeholder ya bi zimanê Kurdî ye. Nivîs, weşan û rûpelên nûçe di vê belgeyê de têne pêşniyar kirin. Ev metn ji bo testkirina layout an jî demo-yê hatiye çêkirin û çend bingehên cihanî yên naveroka gotarê nîşan dide.
|
||||||
|
|
||||||
|
## Destpêk
|
||||||
|
Di destpêka gotarê de, dikarin rêvekên bingehîn û armancên mijarê vebêjin. Tu dikarî vê metnê bikar bînin ji bo şexsî an jî projeyên xwe:
|
||||||
|
|
||||||
|
Lorem ipsum ji bo kurdî:
|
||||||
|
"Rojên nû û şevên hêja, ev nivîs têne çêkirin ku bi awayek nîşanbideke cîhan û hunermendî were afirandin."
|
||||||
|
|
||||||
|
## Lêkolîn û Naverok
|
||||||
|
Di vê beşê de hinek îzahiyên naverokî yên placeholder hatine peyda kirin. Hûn dikarin bi rêza li jêr anînên mifteyî yên gotarê şop bikin:
|
||||||
|
|
||||||
|
- **Mijar:** Di vê gotarê de, mijarên bi zor û hêja têne nîşandan.
|
||||||
|
- **Rêbaz:** Ew kesên ku ji ber vê gotarê şîrove û daxuyanî dikin, çavkaniyên xwe diguhezînin.
|
||||||
|
- **Agahî:** Di vê derbarê de, agahîyên cihanî, dîtin û têgihiştin hatine berhev kirin.
|
||||||
|
|
||||||
|
Di bin vê şexsiyeta, hertişt di dema xwe de têgihiştin û anîn pêşiyê dayîn.
|
||||||
|
|
||||||
|
## Şirove û Kod
|
||||||
|
Di vê paragrafa kêm-kêm de, em dikarin bingehên şiroveyê yên gotarê di kodê de jî şop bikin:
|
||||||
|
|
||||||
|
```python
|
||||||
|
def peyama_kurdî():
|
||||||
|
mesaj = "Her bijî Kurdistan! Rojên baş û serkeftin!"
|
||||||
|
return mesaj
|
||||||
|
|
||||||
|
print(peyama_kurdî())
|
||||||
|
```
|
||||||
|
|
||||||
|
Kodê li ser vê koda simplesa gotinê ye û dikare weşana nûçe an demo-yê projeyan bixebite.
|
||||||
|
|
||||||
|
# Encama Gotarê
|
||||||
|
|
||||||
|
Di encama gotarê de, hûn dikarin her çend beşên bingehîn yên nûçe, daxuyanî û şirove yên navekî bifikirin.
|
||||||
|
Bê guman, ev placeholder bi awayek qelew li ser çalakiya te ya malper, blog an jî her sedema dijîtal tê de karîger e.
|
||||||
2
src/articles/index.toml
Normal file
2
src/articles/index.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
name="index_page"
|
||||||
|
datetime="2024-04-15 13:45:12.123456"
|
||||||
38
src/articles/ku.md
Normal file
38
src/articles/ku.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Navê Gotarê
|
||||||
|
|
||||||
|
[{article_title:example}]({article_url:example})
|
||||||
|
|
||||||
|
Ev gotar, mînakek placeholder ya bi zimanê Kurdî ye. Nivîs, weşan û rûpelên nûçe di vê belgeyê de têne pêşniyar kirin. Ev metn ji bo testkirina layout an jî demo-yê hatiye çêkirin û çend bingehên cihanî yên naveroka gotarê nîşan dide.
|
||||||
|
|
||||||
|
## Destpêk
|
||||||
|
Di destpêka gotarê de, dikarin rêvekên bingehîn û armancên mijarê vebêjin. Tu dikarî vê metnê bikar bînin ji bo şexsî an jî projeyên xwe:
|
||||||
|
|
||||||
|
Lorem ipsum ji bo kurdî:
|
||||||
|
"Rojên nû û şevên hêja, ev nivîs têne çêkirin ku bi awayek nîşanbideke cîhan û hunermendî were afirandin."
|
||||||
|
|
||||||
|
## Lêkolîn û Naverok
|
||||||
|
Di vê beşê de hinek îzahiyên naverokî yên placeholder hatine peyda kirin. Hûn dikarin bi rêza li jêr anînên mifteyî yên gotarê şop bikin:
|
||||||
|
|
||||||
|
- **Mijar:** Di vê gotarê de, mijarên bi zor û hêja têne nîşandan.
|
||||||
|
- **Rêbaz:** Ew kesên ku ji ber vê gotarê şîrove û daxuyanî dikin, çavkaniyên xwe diguhezînin.
|
||||||
|
- **Agahî:** Di vê derbarê de, agahîyên cihanî, dîtin û têgihiştin hatine berhev kirin.
|
||||||
|
|
||||||
|
Di bin vê şexsiyeta, hertişt di dema xwe de têgihiştin û anîn pêşiyê dayîn.
|
||||||
|
|
||||||
|
## Şirove û Kod
|
||||||
|
Di vê paragrafa kêm-kêm de, em dikarin bingehên şiroveyê yên gotarê di kodê de jî şop bikin:
|
||||||
|
|
||||||
|
```python
|
||||||
|
def peyama_kurdî():
|
||||||
|
mesaj = "Her bijî Kurdistan! Rojên baş û serkeftin!"
|
||||||
|
return mesaj
|
||||||
|
|
||||||
|
print(peyama_kurdî())
|
||||||
|
```
|
||||||
|
|
||||||
|
Kodê li ser vê koda simplesa gotinê ye û dikare weşana nûçe an demo-yê projeyan bixebite.
|
||||||
|
|
||||||
|
# Encama Gotarê
|
||||||
|
|
||||||
|
Di encama gotarê de, hûn dikarin her çend beşên bingehîn yên nûçe, daxuyanî û şirove yên navekî bifikirin.
|
||||||
|
Bê guman, ev placeholder bi awayek qelew li ser çalakiya te ya malper, blog an jî her sedema dijîtal tê de karîger e.
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# foo
|
|
||||||
|
|
||||||
Lore ipsum dolor sit amend
|
|
||||||
|
|
||||||
- bar
|
|
||||||
- foobar
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
98
src/templates/article.html
Normal file
98
src/templates/article.html
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<title>{{slug}}</title>
|
||||||
|
<link rel="stylesheet" href="/static/bulma.min.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- Header (Navbar) -->
|
||||||
|
<nav
|
||||||
|
class="navbar is-primary"
|
||||||
|
role="navigation"
|
||||||
|
aria-label="main navigation"
|
||||||
|
>
|
||||||
|
<div class="navbar-brand">
|
||||||
|
<a class="navbar-item" href="#">
|
||||||
|
<strong>Static Translated Site Generator</strong>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<section class="section">
|
||||||
|
{% if translations|length %}
|
||||||
|
<div class="container content">
|
||||||
|
<div class="column is-half is-offset-one-quarter">
|
||||||
|
<h1>Translations</h1>
|
||||||
|
</div>
|
||||||
|
<div class="column is-half is-offset-one-quarter">
|
||||||
|
{% for t in translations %}
|
||||||
|
<div class="card mb-4" lang="{{t.language.code}}">
|
||||||
|
<a href="{{t.url}}" hreflang="{{t.language.code}}" class="card mb-4" style="color: inherit; text-decoration: none;">
|
||||||
|
<div class="card-content">
|
||||||
|
<p class="title">{{t.language.flag}} {{t.title}} </p>
|
||||||
|
<p class="content">
|
||||||
|
{{t.preview}}
|
||||||
|
<br />
|
||||||
|
<time datetime="{{iso_date}}">{{date}}</time>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if children|length %}
|
||||||
|
<div class="container content">
|
||||||
|
<div class="column is-half is-offset-one-quarter">
|
||||||
|
<h1>Child Articles</h1>
|
||||||
|
</div>
|
||||||
|
<div class="column is-half is-offset-one-quarter">
|
||||||
|
{% for c in children %}
|
||||||
|
<div class="card mb-4" >
|
||||||
|
<a href="{{c.url}}" class="card mb-4" style="color: inherit; text-decoration: none;">
|
||||||
|
<div class="card-content">
|
||||||
|
<p class="title">{{c.slug}} </p>
|
||||||
|
<p class="content">
|
||||||
|
<time datetime="{{iso_date}}">{{date}}</time>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<footer class="footer">
|
||||||
|
<div class="content has-text-centered">
|
||||||
|
<p><strong>STSG</strong> by Hazel. © 2025</p>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const userLang = navigator.language || navigator.userLanguage;
|
||||||
|
|
||||||
|
// Normalize and check if the language is not English or German
|
||||||
|
if (!["en", "de", "de-DE"].includes(userLang)) {
|
||||||
|
// Try to find a matching card by language attribute
|
||||||
|
const cardToMove =
|
||||||
|
document.querySelector(`.card[lang^="${userLang.replace("_", "-").toLowerCase()}"]`) ||
|
||||||
|
document.querySelector(`.card[lang^="${userLang.split("-")[0]}"]`);
|
||||||
|
|
||||||
|
if (cardToMove) {
|
||||||
|
const container = cardToMove.parentNode;
|
||||||
|
container.insertBefore(cardToMove, container.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</html>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="{article_language_code}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>STSG</title>
|
<title>{{language.flag}} {{title}}</title>
|
||||||
<link rel="stylesheet" href="/static/bulma.min.css" />
|
<link rel="stylesheet" href="/static/bulma.min.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -14,8 +14,9 @@
|
|||||||
aria-label="main navigation"
|
aria-label="main navigation"
|
||||||
>
|
>
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item" href="#">
|
<a class="navbar-item" href="{{article_url}}">
|
||||||
<strong>Static Translated Site Generator</strong>
|
<strong>{{language.flag}} {{title}}</strong>
|
||||||
|
<time datetime="{{meta.iso_date}}">{{meta.date}}</time>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<content />
|
{{content}}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
25
stsg.toml
Normal file
25
stsg.toml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[setup]
|
||||||
|
source_directory = "src"
|
||||||
|
dist_directory = "dist"
|
||||||
|
|
||||||
|
[formatting]
|
||||||
|
article_preview_length = 400
|
||||||
|
datetime_format = "%d. %B %Y"
|
||||||
|
default_language = "de"
|
||||||
|
|
||||||
|
[languages]
|
||||||
|
[languages.de]
|
||||||
|
native_name = "Schland"
|
||||||
|
priority = 100
|
||||||
|
|
||||||
|
[languages.en]
|
||||||
|
priority = 90
|
||||||
|
|
||||||
|
[languages.ar_sy]
|
||||||
|
priority = 50
|
||||||
|
|
||||||
|
[languages.ku]
|
||||||
|
priority = 49
|
||||||
|
|
||||||
|
[languages.tr]
|
||||||
|
priority = 60
|
||||||
793
stsg/__init__.py
793
stsg/__init__.py
@@ -0,0 +1,793 @@
|
|||||||
|
class config:
|
||||||
|
class setup:
|
||||||
|
source_directory = "src"
|
||||||
|
dist_directory = "dist"
|
||||||
|
|
||||||
|
class formatting:
|
||||||
|
article_preview_length = 200
|
||||||
|
datetime_format = "%d. %B %Y"
|
||||||
|
fallback_language = "en"
|
||||||
|
|
||||||
|
languages = {
|
||||||
|
"af": {
|
||||||
|
"flag": "🇿🇦",
|
||||||
|
"name": "Afrikaans",
|
||||||
|
"native_name": "Afrikaans"
|
||||||
|
},
|
||||||
|
"am": {
|
||||||
|
"flag": "🇪🇹",
|
||||||
|
"name": "Amharic",
|
||||||
|
"native_name": "አማርኛ"
|
||||||
|
},
|
||||||
|
"an": {
|
||||||
|
"flag": "🇪🇸",
|
||||||
|
"name": "Aragonese",
|
||||||
|
"native_name": "aragonés"
|
||||||
|
},
|
||||||
|
"ar": {
|
||||||
|
"flag": "🇸🇦",
|
||||||
|
"name": "Arabic",
|
||||||
|
"native_name": "العربية"
|
||||||
|
},
|
||||||
|
"ar_ae": {
|
||||||
|
"flag": "🇦🇪",
|
||||||
|
"name": "Arabic (UAE)",
|
||||||
|
"native_name": "العربية (الإمارات)"
|
||||||
|
},
|
||||||
|
"ar_bh": {
|
||||||
|
"flag": "🇧🇭",
|
||||||
|
"name": "Arabic (Bahrain)",
|
||||||
|
"native_name": "العربية (البحرين)"
|
||||||
|
},
|
||||||
|
"ar_dz": {
|
||||||
|
"flag": "🇩🇿",
|
||||||
|
"name": "Arabic (Algeria)",
|
||||||
|
"native_name": "العربية (الجزائر)"
|
||||||
|
},
|
||||||
|
"ar_eg": {
|
||||||
|
"flag": "🇪🇬",
|
||||||
|
"name": "Arabic (Egypt)",
|
||||||
|
"native_name": "العربية (مصر)"
|
||||||
|
},
|
||||||
|
"ar_iq": {
|
||||||
|
"flag": "🇮🇶",
|
||||||
|
"name": "Arabic (Iraq)",
|
||||||
|
"native_name": "العربية (العراق)"
|
||||||
|
},
|
||||||
|
"ar_jo": {
|
||||||
|
"flag": "🇯🇴",
|
||||||
|
"name": "Arabic (Jordan)",
|
||||||
|
"native_name": "العربية (الأردن)"
|
||||||
|
},
|
||||||
|
"ar_kw": {
|
||||||
|
"flag": "🇰🇼",
|
||||||
|
"name": "Arabic (Kuwait)",
|
||||||
|
"native_name": "العربية (الكويت)"
|
||||||
|
},
|
||||||
|
"ar_lb": {
|
||||||
|
"flag": "🇱🇧",
|
||||||
|
"name": "Arabic (Lebanon)",
|
||||||
|
"native_name": "العربية (لبنان)"
|
||||||
|
},
|
||||||
|
"ar_ly": {
|
||||||
|
"flag": "🇱🇾",
|
||||||
|
"name": "Arabic (Libya)",
|
||||||
|
"native_name": "العربية (ليبيا)"
|
||||||
|
},
|
||||||
|
"ar_ma": {
|
||||||
|
"flag": "🇲🇦",
|
||||||
|
"name": "Arabic (Morocco)",
|
||||||
|
"native_name": "العربية (المغرب)"
|
||||||
|
},
|
||||||
|
"ar_om": {
|
||||||
|
"flag": "🇴🇲",
|
||||||
|
"name": "Arabic (Oman)",
|
||||||
|
"native_name": "العربية (عُمان)"
|
||||||
|
},
|
||||||
|
"ar_qa": {
|
||||||
|
"flag": "🇶🇦",
|
||||||
|
"name": "Arabic (Qatar)",
|
||||||
|
"native_name": "العربية (قطر)"
|
||||||
|
},
|
||||||
|
"ar_sa": {
|
||||||
|
"flag": "🇸🇦",
|
||||||
|
"name": "Arabic (Saudi Arabia)",
|
||||||
|
"native_name": "العربية (السعودية)"
|
||||||
|
},
|
||||||
|
"ar_sd": {
|
||||||
|
"flag": "🇸🇩",
|
||||||
|
"name": "Arabic (Sudan)",
|
||||||
|
"native_name": "العربية (السودان)"
|
||||||
|
},
|
||||||
|
"ar_sy": {
|
||||||
|
"flag": "🇸🇾",
|
||||||
|
"name": "Arabic (Syria)",
|
||||||
|
"native_name": "العربية (سوريا)",
|
||||||
|
},
|
||||||
|
"ar_tn": {
|
||||||
|
"flag": "🇹🇳",
|
||||||
|
"name": "Arabic (Tunisia)",
|
||||||
|
"native_name": "العربية (تونس)"
|
||||||
|
},
|
||||||
|
"ar_ye": {
|
||||||
|
"flag": "🇾🇪",
|
||||||
|
"name": "Arabic (Yemen)",
|
||||||
|
"native_name": "العربية (اليمن)"
|
||||||
|
},
|
||||||
|
"ars_ae": {
|
||||||
|
"flag": "🇦🇪",
|
||||||
|
"name": "Najdi Arabic (UAE)",
|
||||||
|
"native_name": "نَجْدِيّ"
|
||||||
|
},
|
||||||
|
"ars_arab_sa": {
|
||||||
|
"flag": "🇸🇦",
|
||||||
|
"name": "Najdi Arabic (Saudi Arabia, Arabic Script)",
|
||||||
|
"native_name": "نَجْدِيّ"
|
||||||
|
},
|
||||||
|
"ars_sa": {
|
||||||
|
"flag": "🇸🇦",
|
||||||
|
"name": "Najdi Arabic (Saudi Arabia)",
|
||||||
|
"native_name": "نَجْدِيّ"
|
||||||
|
},
|
||||||
|
"as": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Assamese",
|
||||||
|
"native_name": "অসমীয়া"
|
||||||
|
},
|
||||||
|
"az": {
|
||||||
|
"flag": "🇦🇿",
|
||||||
|
"name": "Azerbaijani",
|
||||||
|
"native_name": "Azərbaycan"
|
||||||
|
},
|
||||||
|
"be": {
|
||||||
|
"flag": "🇧🇾",
|
||||||
|
"name": "Belarusian",
|
||||||
|
"native_name": "Беларуская"
|
||||||
|
},
|
||||||
|
"bg": {
|
||||||
|
"flag": "🇧🇬",
|
||||||
|
"name": "Bulgarian",
|
||||||
|
"native_name": "Български"
|
||||||
|
},
|
||||||
|
"bm": {
|
||||||
|
"flag": "🇲🇱",
|
||||||
|
"name": "Bambara",
|
||||||
|
"native_name": "bamanankan"
|
||||||
|
},
|
||||||
|
"bn": {
|
||||||
|
"flag": "🇧🇩",
|
||||||
|
"name": "Bengali",
|
||||||
|
"native_name": "বাংলা"
|
||||||
|
},
|
||||||
|
"bn_in": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Bengali (India)",
|
||||||
|
"native_name": "বাংলা (ভারত)"
|
||||||
|
},
|
||||||
|
"br": {
|
||||||
|
"flag": "🏴",
|
||||||
|
"name": "Breton",
|
||||||
|
"native_name": "brezhoneg"
|
||||||
|
},
|
||||||
|
"bs": {
|
||||||
|
"flag": "🇧🇦",
|
||||||
|
"name": "Bosnian",
|
||||||
|
"native_name": "Bosanski"
|
||||||
|
},
|
||||||
|
"ca": {
|
||||||
|
"flag": "🇪🇸",
|
||||||
|
"name": "Catalan",
|
||||||
|
"native_name": "Català"
|
||||||
|
},
|
||||||
|
"crh": {
|
||||||
|
"flag": "🇺🇦",
|
||||||
|
"name": "Crimean Tatar",
|
||||||
|
"native_name": "qırımtatarca"
|
||||||
|
},
|
||||||
|
"cs": {
|
||||||
|
"flag": "🇨🇿",
|
||||||
|
"name": "Czech",
|
||||||
|
"native_name": "Čeština"
|
||||||
|
},
|
||||||
|
"cv": {
|
||||||
|
"flag": "🇷🇺",
|
||||||
|
"name": "Chuvash",
|
||||||
|
"native_name": "чӑваш чӗлхи"
|
||||||
|
},
|
||||||
|
"cy": {
|
||||||
|
"flag": "🏴",
|
||||||
|
"name": "Welsh",
|
||||||
|
"native_name": "Cymraeg"
|
||||||
|
},
|
||||||
|
"da": {
|
||||||
|
"flag": "🇩🇰",
|
||||||
|
"name": "Danish",
|
||||||
|
"native_name": "Dansk"
|
||||||
|
},
|
||||||
|
"de": {
|
||||||
|
"flag": "🇩🇪",
|
||||||
|
"name": "German",
|
||||||
|
"native_name": "Deutsch",
|
||||||
|
},
|
||||||
|
"de_at": {
|
||||||
|
"flag": "🇦🇹",
|
||||||
|
"name": "German (Austria)",
|
||||||
|
"native_name": "Deutsch (Österreich)"
|
||||||
|
},
|
||||||
|
"de_be": {
|
||||||
|
"flag": "🇧🇪",
|
||||||
|
"name": "German (Belgium)",
|
||||||
|
"native_name": "Deutsch (Belgien)"
|
||||||
|
},
|
||||||
|
"de_ch": {
|
||||||
|
"flag": "🇨🇭",
|
||||||
|
"name": "German (Switzerland)",
|
||||||
|
"native_name": "Deutsch (Schweiz)"
|
||||||
|
},
|
||||||
|
"dv": {
|
||||||
|
"flag": "🇲🇻",
|
||||||
|
"name": "Dhivehi",
|
||||||
|
"native_name": "ދިވެހި"
|
||||||
|
},
|
||||||
|
"dz": {
|
||||||
|
"flag": "🇧🇹",
|
||||||
|
"name": "Dzongkha",
|
||||||
|
"native_name": "རྫོང་ཁ"
|
||||||
|
},
|
||||||
|
"el": {
|
||||||
|
"flag": "🇬🇷",
|
||||||
|
"name": "Greek",
|
||||||
|
"native_name": "Ελληνικά"
|
||||||
|
},
|
||||||
|
"en": {
|
||||||
|
"flag": "🇺🇸",
|
||||||
|
"name": "English",
|
||||||
|
"native_name": "English",
|
||||||
|
},
|
||||||
|
"en_au": {
|
||||||
|
"flag": "🇦🇺",
|
||||||
|
"name": "English (Australia)",
|
||||||
|
"native_name": "English (Australia)"
|
||||||
|
},
|
||||||
|
"en_ca": {
|
||||||
|
"flag": "🇨🇦",
|
||||||
|
"name": "English (Canada)",
|
||||||
|
"native_name": "English (Canada)"
|
||||||
|
},
|
||||||
|
"en_gb": {
|
||||||
|
"flag": "🇬🇧",
|
||||||
|
"name": "English (UK)",
|
||||||
|
"native_name": "English (UK)",
|
||||||
|
},
|
||||||
|
"en_ie": {
|
||||||
|
"flag": "🇮🇪",
|
||||||
|
"name": "English (Ireland)",
|
||||||
|
"native_name": "English (Ireland)"
|
||||||
|
},
|
||||||
|
"en_in": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "English (India)",
|
||||||
|
"native_name": "English (India)"
|
||||||
|
},
|
||||||
|
"en_nz": {
|
||||||
|
"flag": "🇳🇿",
|
||||||
|
"name": "English (New Zealand)",
|
||||||
|
"native_name": "English (New Zealand)"
|
||||||
|
},
|
||||||
|
"en_us": {
|
||||||
|
"flag": "🇺🇸",
|
||||||
|
"name": "English (US)",
|
||||||
|
"native_name": "English (US)",
|
||||||
|
},
|
||||||
|
"es": {
|
||||||
|
"flag": "🇪🇸",
|
||||||
|
"name": "Spanish",
|
||||||
|
"native_name": "Español"
|
||||||
|
},
|
||||||
|
"es_ar": {
|
||||||
|
"flag": "🇦🇷",
|
||||||
|
"name": "Spanish (Argentina)",
|
||||||
|
"native_name": "Español (Argentina)"
|
||||||
|
},
|
||||||
|
"es_mx": {
|
||||||
|
"flag": "🇲🇽",
|
||||||
|
"name": "Spanish (Mexico)",
|
||||||
|
"native_name": "Español (México)"
|
||||||
|
},
|
||||||
|
"et": {
|
||||||
|
"flag": "🇪🇪",
|
||||||
|
"name": "Estonian",
|
||||||
|
"native_name": "Eesti"
|
||||||
|
},
|
||||||
|
"fa": {
|
||||||
|
"flag": "🇮🇷",
|
||||||
|
"name": "Persian",
|
||||||
|
"native_name": "فارسی"
|
||||||
|
},
|
||||||
|
"ff": {
|
||||||
|
"flag": "🌍",
|
||||||
|
"name": "Fula",
|
||||||
|
"native_name": "Fulfulde"
|
||||||
|
},
|
||||||
|
"fi": {
|
||||||
|
"flag": "🇫🇮",
|
||||||
|
"name": "Finnish",
|
||||||
|
"native_name": "Suomi"
|
||||||
|
},
|
||||||
|
"fo": {
|
||||||
|
"flag": "🇫🇴",
|
||||||
|
"name": "Faroese",
|
||||||
|
"native_name": "føroyskt"
|
||||||
|
},
|
||||||
|
"fr": {
|
||||||
|
"flag": "🇫🇷",
|
||||||
|
"name": "French",
|
||||||
|
"native_name": "Français"
|
||||||
|
},
|
||||||
|
"fr_ca": {
|
||||||
|
"flag": "🇨🇦",
|
||||||
|
"name": "French (Canada)",
|
||||||
|
"native_name": "Français (Canada)"
|
||||||
|
},
|
||||||
|
"fr_ch": {
|
||||||
|
"flag": "🇨🇭",
|
||||||
|
"name": "French (Switzerland)",
|
||||||
|
"native_name": "Français (Suisse)"
|
||||||
|
},
|
||||||
|
"ga": {
|
||||||
|
"flag": "🇮🇪",
|
||||||
|
"name": "Irish",
|
||||||
|
"native_name": "Gaeilge"
|
||||||
|
},
|
||||||
|
"gl": {
|
||||||
|
"flag": "🇪🇸",
|
||||||
|
"name": "Galician",
|
||||||
|
"native_name": "Galego"
|
||||||
|
},
|
||||||
|
"gn": {
|
||||||
|
"flag": "🇵🇾",
|
||||||
|
"name": "Guarani",
|
||||||
|
"native_name": "Avañe'ẽ"
|
||||||
|
},
|
||||||
|
"gu": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Gujarati",
|
||||||
|
"native_name": "ગુજરાતી"
|
||||||
|
},
|
||||||
|
"ha": {
|
||||||
|
"flag": "🇳🇬",
|
||||||
|
"name": "Hausa",
|
||||||
|
"native_name": "هَوُسَ"
|
||||||
|
},
|
||||||
|
"he": {
|
||||||
|
"flag": "🇮🇱",
|
||||||
|
"name": "Hebrew",
|
||||||
|
"native_name": "עברית"
|
||||||
|
},
|
||||||
|
"hi": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Hindi",
|
||||||
|
"native_name": "हिन्दी"
|
||||||
|
},
|
||||||
|
"hr": {
|
||||||
|
"flag": "🇭🇷",
|
||||||
|
"name": "Croatian",
|
||||||
|
"native_name": "Hrvatski"
|
||||||
|
},
|
||||||
|
"ht": {
|
||||||
|
"flag": "🇭🇹",
|
||||||
|
"name": "Haitian Creole",
|
||||||
|
"native_name": "Kreyòl ayisyen"
|
||||||
|
},
|
||||||
|
"hu": {
|
||||||
|
"flag": "🇭🇺",
|
||||||
|
"name": "Hungarian",
|
||||||
|
"native_name": "Magyar"
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"flag": "🇮🇩",
|
||||||
|
"name": "Indonesian",
|
||||||
|
"native_name": "Bahasa Indonesia"
|
||||||
|
},
|
||||||
|
"io": {
|
||||||
|
"flag": "🌍",
|
||||||
|
"name": "Ido",
|
||||||
|
"native_name": "Ido"
|
||||||
|
},
|
||||||
|
"is": {
|
||||||
|
"flag": "🇮🇸",
|
||||||
|
"name": "Icelandic",
|
||||||
|
"native_name": "Íslenska"
|
||||||
|
},
|
||||||
|
"it": {
|
||||||
|
"flag": "🇮🇹",
|
||||||
|
"name": "Italian",
|
||||||
|
"native_name": "Italiano"
|
||||||
|
},
|
||||||
|
"ja": {
|
||||||
|
"flag": "🇯🇵",
|
||||||
|
"name": "Japanese",
|
||||||
|
"native_name": "日本語"
|
||||||
|
},
|
||||||
|
"jv_id": {
|
||||||
|
"flag": "🇮🇩",
|
||||||
|
"name": "Javanese (Indonesia)",
|
||||||
|
"native_name": "basa jawa"
|
||||||
|
},
|
||||||
|
"ka": {
|
||||||
|
"flag": "🇬🇪",
|
||||||
|
"name": "Georgian",
|
||||||
|
"native_name": "ქართული"
|
||||||
|
},
|
||||||
|
"kg": {
|
||||||
|
"flag": "🇨🇬",
|
||||||
|
"name": "Kongo",
|
||||||
|
"native_name": "KiKongo"
|
||||||
|
},
|
||||||
|
"kj": {
|
||||||
|
"flag": "🇳🇦",
|
||||||
|
"name": "Kuanyama",
|
||||||
|
"native_name": "Oshikwanyama"
|
||||||
|
},
|
||||||
|
"kk": {
|
||||||
|
"flag": "🇰🇿",
|
||||||
|
"name": "Kazakh",
|
||||||
|
"native_name": "Қазақ"
|
||||||
|
},
|
||||||
|
"kl": {
|
||||||
|
"flag": "🇬🇱",
|
||||||
|
"name": "Kalaallisut",
|
||||||
|
"native_name": "kalaallisut"
|
||||||
|
},
|
||||||
|
"km": {
|
||||||
|
"flag": "🇰🇭",
|
||||||
|
"name": "Khmer",
|
||||||
|
"native_name": "ខ្មែរ"
|
||||||
|
},
|
||||||
|
"ko": {
|
||||||
|
"flag": "🇰🇷",
|
||||||
|
"name": "Korean",
|
||||||
|
"native_name": "한국어"
|
||||||
|
},
|
||||||
|
"ks": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Kashmiri",
|
||||||
|
"native_name": "کٲشُر"
|
||||||
|
},
|
||||||
|
"ku": {
|
||||||
|
"flag": "🇮🇶",
|
||||||
|
"name": "Kurdish",
|
||||||
|
"native_name": "Kurdî",
|
||||||
|
},
|
||||||
|
"lo": {
|
||||||
|
"flag": "🇱🇦",
|
||||||
|
"name": "Lao",
|
||||||
|
"native_name": "ລາວ"
|
||||||
|
},
|
||||||
|
"lt": {
|
||||||
|
"flag": "🇱🇹",
|
||||||
|
"name": "Lithuanian",
|
||||||
|
"native_name": "Lietuvių"
|
||||||
|
},
|
||||||
|
"lv": {
|
||||||
|
"flag": "🇱🇻",
|
||||||
|
"name": "Latvian",
|
||||||
|
"native_name": "Latviešu"
|
||||||
|
},
|
||||||
|
"mg": {
|
||||||
|
"flag": "🇲🇬",
|
||||||
|
"name": "Malagasy",
|
||||||
|
"native_name": "Malagasy"
|
||||||
|
},
|
||||||
|
"mg_mg": {
|
||||||
|
"flag": "🇲🇬",
|
||||||
|
"name": "Malagasy (Madagascar)",
|
||||||
|
"native_name": "malagasy"
|
||||||
|
},
|
||||||
|
"mh": {
|
||||||
|
"flag": "🇲🇭",
|
||||||
|
"name": "Marshallese",
|
||||||
|
"native_name": "Kajin M̧ajeļ"
|
||||||
|
},
|
||||||
|
"mk": {
|
||||||
|
"flag": "🇲🇰",
|
||||||
|
"name": "Macedonian",
|
||||||
|
"native_name": "Македонски"
|
||||||
|
},
|
||||||
|
"mn_mn": {
|
||||||
|
"flag": "🇲🇳",
|
||||||
|
"name": "Mongolian (Mongolia)",
|
||||||
|
"native_name": "Монгол хэл"
|
||||||
|
},
|
||||||
|
"mr_in": {
|
||||||
|
"flag": "🇮🇳",
|
||||||
|
"name": "Marathi (India)",
|
||||||
|
"native_name": "मराठी"
|
||||||
|
},
|
||||||
|
"ms": {
|
||||||
|
"flag": "🇲🇾",
|
||||||
|
"name": "Malay",
|
||||||
|
"native_name": "Bahasa Melayu"
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
"flag": "🇲🇲",
|
||||||
|
"name": "Burmese",
|
||||||
|
"native_name": "မြန်မာဘာသာ"
|
||||||
|
},
|
||||||
|
"na": {
|
||||||
|
"flag": "🇳🇷",
|
||||||
|
"name": "Nauruan",
|
||||||
|
"native_name": "Dorerin Naoero"
|
||||||
|
},
|
||||||
|
"nb": {
|
||||||
|
"flag": "🇳🇴",
|
||||||
|
"name": "Norwegian Bokmål",
|
||||||
|
"native_name": "Norsk Bokmål"
|
||||||
|
},
|
||||||
|
"ng": {
|
||||||
|
"flag": "🇳🇦",
|
||||||
|
"name": "Ndonga",
|
||||||
|
"native_name": "Oshindonga"
|
||||||
|
},
|
||||||
|
"nl": {
|
||||||
|
"flag": "🇳🇱",
|
||||||
|
"name": "Dutch",
|
||||||
|
"native_name": "Nederlands"
|
||||||
|
},
|
||||||
|
"om": {
|
||||||
|
"flag": "🇪🇹",
|
||||||
|
"name": "Oromo",
|
||||||
|
"native_name": "Afaan Oromoo"
|
||||||
|
},
|
||||||
|
"os": {
|
||||||
|
"flag": "🇷🇺",
|
||||||
|
"name": "Ossetian",
|
||||||
|
"native_name": "ирон æвзаг"
|
||||||
|
},
|
||||||
|
"pl": {
|
||||||
|
"flag": "🇵🇱",
|
||||||
|
"name": "Polish",
|
||||||
|
"native_name": "Polski"
|
||||||
|
},
|
||||||
|
"pt": {
|
||||||
|
"flag": "🇵🇹",
|
||||||
|
"name": "Portuguese",
|
||||||
|
"native_name": "Português"
|
||||||
|
},
|
||||||
|
"pt_br": {
|
||||||
|
"flag": "🇧🇷",
|
||||||
|
"name": "Portuguese (Brazil)",
|
||||||
|
"native_name": "Português (Brasil)"
|
||||||
|
},
|
||||||
|
"qu": {
|
||||||
|
"flag": "🇵🇪",
|
||||||
|
"name": "Quechua",
|
||||||
|
"native_name": "Runa Simi"
|
||||||
|
},
|
||||||
|
"ro": {
|
||||||
|
"flag": "🇷🇴",
|
||||||
|
"name": "Romanian",
|
||||||
|
"native_name": "Română"
|
||||||
|
},
|
||||||
|
"ru": {
|
||||||
|
"flag": "🇷🇺",
|
||||||
|
"name": "Russian",
|
||||||
|
"native_name": "Русский"
|
||||||
|
},
|
||||||
|
"rw": {
|
||||||
|
"flag": "🇷🇼",
|
||||||
|
"name": "Kinyarwanda",
|
||||||
|
"native_name": "Ikinyarwanda"
|
||||||
|
},
|
||||||
|
"sc": {
|
||||||
|
"flag": "🇮🇹",
|
||||||
|
"name": "Sardinian",
|
||||||
|
"native_name": "sardu"
|
||||||
|
},
|
||||||
|
"sg": {
|
||||||
|
"flag": "🇨🇫",
|
||||||
|
"name": "Sango",
|
||||||
|
"native_name": "yângâ tî sängö"
|
||||||
|
},
|
||||||
|
"sk": {
|
||||||
|
"flag": "🇸🇰",
|
||||||
|
"name": "Slovak",
|
||||||
|
"native_name": "Slovenčina"
|
||||||
|
},
|
||||||
|
"sl": {
|
||||||
|
"flag": "🇸🇮",
|
||||||
|
"name": "Slovenian",
|
||||||
|
"native_name": "Slovenščina"
|
||||||
|
},
|
||||||
|
"sm": {
|
||||||
|
"flag": "🇼🇸",
|
||||||
|
"name": "Samoan",
|
||||||
|
"native_name": "Gagana Samoa"
|
||||||
|
},
|
||||||
|
"sn": {
|
||||||
|
"flag": "🇿🇼",
|
||||||
|
"name": "Shona",
|
||||||
|
"native_name": "chiShona"
|
||||||
|
},
|
||||||
|
"so": {
|
||||||
|
"flag": "🇸🇴",
|
||||||
|
"name": "Somali",
|
||||||
|
"native_name": "Soomaaliga"
|
||||||
|
},
|
||||||
|
"sr": {
|
||||||
|
"flag": "🇷🇸",
|
||||||
|
"name": "Serbian",
|
||||||
|
"native_name": "Српски"
|
||||||
|
},
|
||||||
|
"ss": {
|
||||||
|
"flag": "🇸🇿",
|
||||||
|
"name": "Swati",
|
||||||
|
"native_name": "SiSwati"
|
||||||
|
},
|
||||||
|
"st": {
|
||||||
|
"flag": "🇱🇸",
|
||||||
|
"name": "Southern Sotho",
|
||||||
|
"native_name": "Sesotho"
|
||||||
|
},
|
||||||
|
"su_id": {
|
||||||
|
"flag": "🇮🇩",
|
||||||
|
"name": "Sundanese (Indonesia)",
|
||||||
|
"native_name": "basa sunda"
|
||||||
|
},
|
||||||
|
"sv": {
|
||||||
|
"flag": "🇸🇪",
|
||||||
|
"name": "Swedish",
|
||||||
|
"native_name": "Svenska"
|
||||||
|
},
|
||||||
|
"th": {
|
||||||
|
"flag": "🇹🇭",
|
||||||
|
"name": "Thai",
|
||||||
|
"native_name": "ไทย"
|
||||||
|
},
|
||||||
|
"tk": {
|
||||||
|
"flag": "🇹🇲",
|
||||||
|
"name": "Turkmen",
|
||||||
|
"native_name": "Türkmen"
|
||||||
|
},
|
||||||
|
"tn": {
|
||||||
|
"flag": "🇧🇼",
|
||||||
|
"name": "Tswana",
|
||||||
|
"native_name": "Setswana"
|
||||||
|
},
|
||||||
|
"to": {
|
||||||
|
"flag": "🇹🇴",
|
||||||
|
"name": "Tongan",
|
||||||
|
"native_name": "faka-Tonga"
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
"flag": "🇹🇷",
|
||||||
|
"name": "Turkish",
|
||||||
|
"native_name": "Türkçe",
|
||||||
|
},
|
||||||
|
"ts": {
|
||||||
|
"flag": "🇿🇦",
|
||||||
|
"name": "Tsonga",
|
||||||
|
"native_name": "Xitsonga"
|
||||||
|
},
|
||||||
|
"ts_zw": {
|
||||||
|
"flag": "🇿🇼",
|
||||||
|
"name": "Tsonga (Zimbabwe)",
|
||||||
|
"native_name": "xitsonga"
|
||||||
|
},
|
||||||
|
"ty": {
|
||||||
|
"flag": "🇵🇫",
|
||||||
|
"name": "Tahitian",
|
||||||
|
"native_name": "Reo Tahiti"
|
||||||
|
},
|
||||||
|
"uk": {
|
||||||
|
"flag": "🇺🇦",
|
||||||
|
"name": "Ukrainian",
|
||||||
|
"native_name": "Українська"
|
||||||
|
},
|
||||||
|
"ur": {
|
||||||
|
"flag": "🇵🇰",
|
||||||
|
"name": "Urdu",
|
||||||
|
"native_name": "اردو"
|
||||||
|
},
|
||||||
|
"uz": {
|
||||||
|
"flag": "🇺🇿",
|
||||||
|
"name": "Uzbek",
|
||||||
|
"native_name": "oʻzbek"
|
||||||
|
},
|
||||||
|
"ve": {
|
||||||
|
"flag": "🇿🇦",
|
||||||
|
"name": "Venda",
|
||||||
|
"native_name": "Tshivenda"
|
||||||
|
},
|
||||||
|
"vi": {
|
||||||
|
"flag": "🇻🇳",
|
||||||
|
"name": "Vietnamese",
|
||||||
|
"native_name": "Tiếng Việt"
|
||||||
|
},
|
||||||
|
"vo": {
|
||||||
|
"flag": "🌍",
|
||||||
|
"name": "Volapük",
|
||||||
|
"native_name": "Volapük"
|
||||||
|
},
|
||||||
|
"wa": {
|
||||||
|
"flag": "🇧🇪",
|
||||||
|
"name": "Walloon",
|
||||||
|
"native_name": "walon"
|
||||||
|
},
|
||||||
|
"xh": {
|
||||||
|
"flag": "🇿🇦",
|
||||||
|
"name": "Xhosa",
|
||||||
|
"native_name": "isiXhosa"
|
||||||
|
},
|
||||||
|
"yi": {
|
||||||
|
"flag": "🌍",
|
||||||
|
"name": "Yiddish",
|
||||||
|
"native_name": "ייִדיש"
|
||||||
|
},
|
||||||
|
"yo": {
|
||||||
|
"flag": "🇳🇬",
|
||||||
|
"name": "Yoruba",
|
||||||
|
"native_name": "Yorùbá"
|
||||||
|
},
|
||||||
|
"zh": {
|
||||||
|
"flag": "🇨🇳",
|
||||||
|
"name": "Chinese",
|
||||||
|
"native_name": "中文"
|
||||||
|
},
|
||||||
|
"zh_hk": {
|
||||||
|
"flag": "🇭🇰",
|
||||||
|
"name": "Chinese (Hong Kong)",
|
||||||
|
"native_name": "中文(香港)"
|
||||||
|
},
|
||||||
|
"zh_tw": {
|
||||||
|
"flag": "🇹🇼",
|
||||||
|
"name": "Chinese (Taiwan)",
|
||||||
|
"native_name": "中文(台灣)"
|
||||||
|
},
|
||||||
|
"zu": {
|
||||||
|
"flag": "🇿🇦",
|
||||||
|
"name": "Zulu",
|
||||||
|
"native_name": "isiZulu"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if True:
|
||||||
|
import toml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def process_data_dict(data: dict, existing: dict):
|
||||||
|
for key, value in data.items():
|
||||||
|
if key not in existing:
|
||||||
|
existing[key] = value
|
||||||
|
continue
|
||||||
|
|
||||||
|
if isinstance(value, dict):
|
||||||
|
if isinstance(existing[key], dict):
|
||||||
|
process_data_dict(value, existing[key])
|
||||||
|
continue
|
||||||
|
|
||||||
|
existing[key] = value
|
||||||
|
|
||||||
|
def process_data(data: dict, obj):
|
||||||
|
for key, value in data.items():
|
||||||
|
if not hasattr(obj, key):
|
||||||
|
continue
|
||||||
|
|
||||||
|
existing = getattr(obj, key)
|
||||||
|
if isinstance(existing, dict):
|
||||||
|
process_data_dict(value, existing)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
if isinstance(value, dict):
|
||||||
|
process_data(value, getattr(obj, key))
|
||||||
|
continue
|
||||||
|
|
||||||
|
setattr(obj, key, value)
|
||||||
|
|
||||||
|
|
||||||
|
config_file = Path("stsg.toml")
|
||||||
|
if config_file.exists() and config_file.is_file():
|
||||||
|
with config_file.open("r") as f:
|
||||||
|
process_data(toml.loads(f.read()), config)
|
||||||
|
|||||||
@@ -5,9 +5,14 @@ import time
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .config import SOURCE_DIRECTORY, CODE_DIRECTORY
|
|
||||||
|
from . import config
|
||||||
from .build import build as complete_build
|
from .build import build as complete_build
|
||||||
|
|
||||||
|
|
||||||
|
CODE_DIRECTORY = "stsg"
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger("stsg")
|
logger = logging.getLogger("stsg")
|
||||||
|
|
||||||
@@ -69,7 +74,7 @@ def build_on_change():
|
|||||||
build()
|
build()
|
||||||
|
|
||||||
observer = Observer()
|
observer = Observer()
|
||||||
observer.schedule(MarkdownChangeHandler(), path=SOURCE_DIRECTORY, recursive=True)
|
observer.schedule(MarkdownChangeHandler(), path=config.setup.source_directory, recursive=True)
|
||||||
observer.start()
|
observer.start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -97,3 +102,4 @@ def hot_reload():
|
|||||||
observer.stop()
|
observer.stop()
|
||||||
|
|
||||||
observer.join()
|
observer.join()
|
||||||
|
|
||||||
|
|||||||
341
stsg/build.py
341
stsg/build.py
@@ -1,127 +1,280 @@
|
|||||||
|
from __future__ import annotations
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import markdown
|
import markdown
|
||||||
from typing import Optional
|
from typing import Optional, Union, Dict, Generator, List, DefaultDict, Any
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from collections import defaultdict
|
||||||
|
import toml
|
||||||
|
from datetime import datetime
|
||||||
|
import jinja2
|
||||||
|
|
||||||
from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, STATIC_DIRECTORY
|
from . import config
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("stsg.build")
|
def replace_values(template: str, values: Dict[str, str]) -> str:
|
||||||
|
for key, value in values.items():
|
||||||
|
template = template.replace("{" + key + "}", value)
|
||||||
|
|
||||||
|
return template
|
||||||
|
|
||||||
|
|
||||||
def copy_static(src, dst):
|
def get_first_header_content(content, fallback: str = ""):
|
||||||
if not os.path.exists(src):
|
soup = BeautifulSoup(content, 'html.parser')
|
||||||
logger.warn("The static folder '%s' wasn't defined.", src)
|
for level in range(1, 7):
|
||||||
return
|
header = soup.find(f'h{level}')
|
||||||
|
if header:
|
||||||
|
return header.get_text(strip=True)
|
||||||
|
|
||||||
logger.info("copying static files from '%s' to '%r'", src, dst)
|
return fallback
|
||||||
|
|
||||||
os.makedirs(dst, exist_ok=True)
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(src):
|
def shorten_text_and_clean(html_string, max_length=config.formatting.article_preview_length):
|
||||||
if any(p.startswith(".") for p in Path(root).parts):
|
soup = BeautifulSoup(html_string, 'html.parser')
|
||||||
continue
|
|
||||||
|
|
||||||
# Compute relative path from the source root
|
# Keep track of total characters added
|
||||||
rel_path = os.path.relpath(root, src)
|
total_chars = 0
|
||||||
dest_dir = os.path.join(dst, rel_path)
|
finished = False
|
||||||
|
|
||||||
os.makedirs(dest_dir, exist_ok=True)
|
# Function to recursively trim and clean text
|
||||||
|
def process_element(element):
|
||||||
|
nonlocal total_chars, finished
|
||||||
|
|
||||||
for file in files:
|
for child in list(element.children):
|
||||||
if file.startswith("."):
|
if finished:
|
||||||
|
child.extract()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
src_file = os.path.join(root, file)
|
if isinstance(child, str):
|
||||||
dest_file = os.path.join(dest_dir, file)
|
remaining = max_length - total_chars
|
||||||
shutil.copy2(src_file, dest_file)
|
if remaining <= 0:
|
||||||
|
child.extract()
|
||||||
|
finished = True
|
||||||
|
elif len(child) > remaining:
|
||||||
|
child.replace_with(child[:remaining] + '...')
|
||||||
|
total_chars = max_length
|
||||||
|
finished = True
|
||||||
|
else:
|
||||||
|
total_chars += len(child)
|
||||||
|
elif hasattr(child, 'children'):
|
||||||
|
process_element(child)
|
||||||
|
# Remove empty tags
|
||||||
|
if not child.text.strip():
|
||||||
|
child.decompose()
|
||||||
|
|
||||||
|
process_element(soup)
|
||||||
|
|
||||||
|
return str(soup)
|
||||||
|
|
||||||
|
|
||||||
class Context:
|
def stem_to_language_code(stem: str) -> str:
|
||||||
def __init__(self, root: str = SOURCE_DIRECTORY):
|
language_code = stem.lower().replace("-", "_")
|
||||||
self.file = None
|
|
||||||
|
|
||||||
current_root = Path(root)
|
|
||||||
while current_root.parts and self.file is None:
|
|
||||||
current_file = Path(current_root, "index.html")
|
|
||||||
if current_file.exists() and current_file.is_file:
|
|
||||||
self.file = current_file
|
|
||||||
|
|
||||||
current_root = current_root.parent
|
|
||||||
|
|
||||||
if self.file is None:
|
|
||||||
logger.error("couldn't find context for %s", root)
|
|
||||||
exit(1)
|
|
||||||
logger.info("%s found context %r", root, str(self.file))
|
|
||||||
|
|
||||||
def get_text(self, **placeholder_values: dict):
|
|
||||||
text = self.file.read_text()
|
|
||||||
|
|
||||||
for key, value in placeholder_values.items():
|
|
||||||
text = text.replace(f"<{key}/>", value)
|
|
||||||
text = text.replace(f"<{key} />", value)
|
|
||||||
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def convert_md(src: Path, dst: Path, context: Optional[Context] = None):
|
|
||||||
html_content = markdown.markdown(src.read_text())
|
|
||||||
context = Context(str(src.parent))
|
|
||||||
full_page = context.get_text(content=html_content)
|
|
||||||
|
|
||||||
folder_dst = dst.parent / dst.name.replace(".md", "")
|
|
||||||
folder_dst.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
with Path(folder_dst, "index.html").open("w") as f:
|
|
||||||
f.write(full_page)
|
|
||||||
|
|
||||||
|
|
||||||
class CustomLanguageCode:
|
|
||||||
def __init__(self, file: Path):
|
|
||||||
self.file: Path = file
|
|
||||||
|
|
||||||
@property
|
|
||||||
def language_code(self) -> str:
|
|
||||||
return self.file.name.replace(".md", "")
|
|
||||||
|
|
||||||
@property
|
if language_code in config.languages:
|
||||||
def relative_url(self) -> str:
|
return language_code
|
||||||
return str(self.file)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
language_code = language_code.split("_")[0]
|
||||||
return f"{self.language_code}"
|
if language_code in config.languages:
|
||||||
|
return language_code
|
||||||
|
|
||||||
|
logger.error("Didn't recognize %s as a valid language code, add it to the config, or fix your structure.", stem)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def walk_directory(root):
|
|
||||||
src_path = Path(SOURCE_DIRECTORY, root)
|
|
||||||
dst_path = Path(DIST_DIRECTORY, root)
|
|
||||||
|
|
||||||
language_codes_found = []
|
class TemplateDict(dict):
|
||||||
|
def __init__(self, folder: Path):
|
||||||
|
self.folder = folder
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
for current_full_path in src_path.iterdir():
|
def __missing__(self, name: str) -> jinja2.Template:
|
||||||
current_name = Path(current_full_path).name
|
f = self.folder / (name + ".html")
|
||||||
current_dst = Path(dst_path, current_name)
|
if not f.exists():
|
||||||
current_src = Path(src_path, current_name)
|
logger.error("no template with the name %s exists", name)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
if current_name == "static":
|
t = jinja2.Template(f.read_text())
|
||||||
copy_static(current_src, current_dst)
|
self[name] = t
|
||||||
continue
|
return t
|
||||||
|
|
||||||
|
TEMPLATE: Dict[str, jinja2.Template] = TemplateDict(Path(config.setup.source_directory, "templates"))
|
||||||
|
|
||||||
|
class LanguageDict(dict):
|
||||||
|
def __missing__(self, key: str):
|
||||||
|
if key not in config.languages:
|
||||||
|
raise KeyError(key)
|
||||||
|
|
||||||
|
lang_dict = config.languages[key]
|
||||||
|
lang_dict["priority"] = lang_dict.get("priority", 0)
|
||||||
|
|
||||||
|
elements = key.split("_")
|
||||||
|
if len(elements) > 1:
|
||||||
|
elements[-1] = elements[-1].upper()
|
||||||
|
lang_dict["code"] = "-".join(elements)
|
||||||
|
|
||||||
|
return lang_dict
|
||||||
|
|
||||||
|
LANGUAGES = LanguageDict()
|
||||||
|
|
||||||
|
|
||||||
|
class ArticleTranslation:
|
||||||
|
def __init__(self, file: Path, article: Article):
|
||||||
|
self.file = file
|
||||||
|
self.article = article
|
||||||
|
|
||||||
|
self.context: Dict[str, Any] = {}
|
||||||
|
|
||||||
|
# initializing the location of the article translation
|
||||||
|
self.language_code = stem_to_language_code(self.file.stem)
|
||||||
|
self.location_in_tree = [self.language_code, *self.article.location_in_tree]
|
||||||
|
self.url = "/" + "/".join(self.location_in_tree)
|
||||||
|
self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree)
|
||||||
|
|
||||||
|
self.priority = LANGUAGES[self.language_code]["priority"]
|
||||||
|
self.real_language_code = LANGUAGES[self.language_code]["code"]
|
||||||
|
|
||||||
|
# TODO remove
|
||||||
|
self.article_content = self.file.read_text()
|
||||||
|
self.article_preview = self.article_content[:config.formatting.article_preview_length] + "..."
|
||||||
|
if self.file.suffix == ".md":
|
||||||
|
self.article_content = markdown.markdown(self.article_content)
|
||||||
|
self.article_preview = markdown.markdown(self.article_preview)
|
||||||
|
|
||||||
|
self.title = get_first_header_content(self.article_content, fallback="")
|
||||||
|
|
||||||
if current_name.endswith(".md"):
|
def __init_context__(self):
|
||||||
convert_md(current_src, current_dst)
|
self.context["meta"] = self.article.context_shared
|
||||||
|
self.context["url"] = self.url
|
||||||
language_codes_found.append(CustomLanguageCode(Path(root, current_name)))
|
self.context["language"] = LANGUAGES[self.language_code]
|
||||||
continue
|
self.context["article_url"] = self.article.url
|
||||||
|
|
||||||
if current_src.is_dir():
|
html_content = self.file.read_text()
|
||||||
walk_directory(Path(root, current_full_path.name))
|
if self.file.suffix == ".md":
|
||||||
|
html_content = markdown.markdown(html_content)
|
||||||
|
|
||||||
print(language_codes_found)
|
self.context["title"] = get_first_header_content(html_content, fallback=LANGUAGES[self.language_code]["native_name"])
|
||||||
|
self.context["content"] = html_content
|
||||||
|
self.context["preview"] = shorten_text_and_clean(html_string=html_content)
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
self.dist_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
with Path(self.dist_path, "index.html").open("w") as f:
|
||||||
|
f.write(TEMPLATE["article_translation"].render(self.context))
|
||||||
|
|
||||||
|
|
||||||
|
class Article:
|
||||||
|
def __init__(self, directory: Path, location_in_tree: Optional[List[str]] = None, is_root: bool = False, parent: Optional[Article] = None):
|
||||||
|
self.directory = directory
|
||||||
|
|
||||||
|
self.context: Dict[str, Any] = {}
|
||||||
|
self.context_shared: Dict[str, Any] = {}
|
||||||
|
if parent is not None:
|
||||||
|
self.context["parent"] = parent.context_shared
|
||||||
|
|
||||||
|
# initializing the config values of the article
|
||||||
|
config_file = self.directory / "index.toml"
|
||||||
|
self.config = toml.load(config_file) if config_file.exists() else {}
|
||||||
|
|
||||||
|
# initializing the location and slug of the article
|
||||||
|
self.slug = self.config.get("name", self.directory.name)
|
||||||
|
if self.slug in ARTICLE_LAKE:
|
||||||
|
logger.error("two articles have the same name at %s and %r", ARTICLE_LAKE[self.slug].directory, self.directory)
|
||||||
|
exit(1)
|
||||||
|
ARTICLE_LAKE[self.slug] = self
|
||||||
|
|
||||||
|
self.location_in_tree: List[str] = location_in_tree or []
|
||||||
|
if not is_root:
|
||||||
|
self.location_in_tree.append(self.slug)
|
||||||
|
self.url = "/" + "/".join(self.location_in_tree)
|
||||||
|
self.dist_path = Path(config.setup.dist_directory, *self.location_in_tree)
|
||||||
|
|
||||||
|
# build the tree
|
||||||
|
self.child_articles: List[Article] = []
|
||||||
|
self.article_translations_list: List[ArticleTranslation] = []
|
||||||
|
self.article_translations_map: Dict[str, ArticleTranslation] = {}
|
||||||
|
|
||||||
|
for c in self.directory.iterdir():
|
||||||
|
if c.name == "index.toml":
|
||||||
|
continue
|
||||||
|
|
||||||
|
if c.is_file():
|
||||||
|
at = ArticleTranslation(c, self)
|
||||||
|
self.article_translations_list.append(at)
|
||||||
|
self.article_translations_map[at.language_code] = at
|
||||||
|
elif c.is_dir():
|
||||||
|
self.child_articles.append(Article(
|
||||||
|
directory=c,
|
||||||
|
location_in_tree=self.location_in_tree.copy(),
|
||||||
|
parent=self,
|
||||||
|
))
|
||||||
|
|
||||||
|
self.article_translations_list.sort(key=lambda a: a.priority, reverse=True)
|
||||||
|
|
||||||
|
logger.info("found %s at %s with the translations %s", self.slug, ".".join(list(self.location_in_tree)), ",".join(self.article_translations_map.keys()))
|
||||||
|
|
||||||
|
def __init_context__(self):
|
||||||
|
self.context_shared["url"] = self.url
|
||||||
|
self.context_shared["slug"] = self.slug
|
||||||
|
|
||||||
|
modified_at = datetime.fromisoformat(self.config["datetime"]) if "datetime" in self.config else datetime.fromtimestamp(self.directory.stat().st_mtime)
|
||||||
|
self.context_shared["date"] = modified_at.strftime(config.formatting.datetime_format)
|
||||||
|
self.context_shared["iso_date"] = modified_at.isoformat()
|
||||||
|
|
||||||
|
self.context.update(self.context_shared)
|
||||||
|
|
||||||
|
# recursive context structures
|
||||||
|
translation_list = self.context["translations"] = []
|
||||||
|
child_article_list = self.context["children"] = []
|
||||||
|
|
||||||
|
for article_translation in self.article_translations_list:
|
||||||
|
self.context[article_translation.real_language_code] = article_translation.context
|
||||||
|
translation_list.append(article_translation.context)
|
||||||
|
|
||||||
|
for child_article in self.child_articles:
|
||||||
|
child_article_list.append(child_article.context)
|
||||||
|
|
||||||
|
# recursively build context
|
||||||
|
for at in self.article_translations_list:
|
||||||
|
at.__init_context__()
|
||||||
|
for a in self.child_articles:
|
||||||
|
a.__init_context__()
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
self.dist_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
with Path(self.dist_path, "index.html").open("w") as f:
|
||||||
|
f.write(TEMPLATE["article"].render(self.context))
|
||||||
|
|
||||||
|
for at in self.article_translations_list:
|
||||||
|
at.build()
|
||||||
|
|
||||||
|
for ac in self.child_articles:
|
||||||
|
ac.build()
|
||||||
|
|
||||||
|
|
||||||
|
# GLOBALS
|
||||||
|
logger = logging.getLogger("stsg.build")
|
||||||
|
ARTICLE_LAKE: Dict[str, Article] = {}
|
||||||
|
ARTICLE_REFERENCE_VALUES: DefaultDict[str, Dict[str, str]] = defaultdict(dict)
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
logger.info("building static page")
|
logger.info("starting build process...")
|
||||||
walk_directory("")
|
|
||||||
|
logger.info("copying static folder...")
|
||||||
|
shutil.copytree(Path(config.setup.source_directory, "static"), Path(config.setup.dist_directory, "static"), dirs_exist_ok=True)
|
||||||
|
|
||||||
|
logger.info("building page tree...")
|
||||||
|
tree = Article(directory=Path(config.setup.source_directory, "articles"), is_root=True)
|
||||||
|
|
||||||
|
logger.info("compiling tree context...")
|
||||||
|
tree.__init_context__()
|
||||||
|
|
||||||
|
import json
|
||||||
|
with Path("context.json").open("w") as f:
|
||||||
|
json.dump(tree.context, f, indent=4)
|
||||||
|
|
||||||
|
logger.info("dumping page tree...")
|
||||||
|
tree.build()
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
SOURCE_DIRECTORY = "src"
|
|
||||||
DIST_DIRECTORY = "dist"
|
|
||||||
|
|
||||||
# relative to SOURCE_DIRECTORY / DIST_DIRECTORY
|
|
||||||
STATIC_DIRECTORY = "static"
|
|
||||||
|
|
||||||
# FOR DEVELOPMENT
|
|
||||||
|
|
||||||
CODE_DIRECTORY = "stsg"
|
|
||||||
Reference in New Issue
Block a user