diff --git a/README.md b/README.md index 3822def..be12478 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ A full example to generate Monsters Game Cards based on [Dungeon World](http://w [![Illustration: Example card deck of monsters, by Dustin Andrew](pic/MonsterCards_partial.png)](https://github.com/berteh/ScribusGenerator/raw/master/example/MonsterCards/MonsterCards_partial.pdf) +### Changes in NEXT-RECORD syntax Please note Scribus Generator v2.8 (from January 2019) changed the syntax of the ["Next Record" feature](https://github.com/berteh/ScribusGenerator#multiple-records-on-a-single-page) to a less confusing name, as per [suggestion #118](https://github.com/berteh/ScribusGenerator/issues/118) @@ -340,6 +341,11 @@ toggle unaligned output with the ```\a``` switch, activate a comma as a separato You can use ```sqlite3 -csv``` in command line or ```.mode csv``` in sqlite's interactive shell +#### Scripts + +Various scripts are available in the ``utils`` folder to facilitate your use of Scribus Generator. +Check out the [related README](https://github.com/berteh/ScribusGenerator/blob/master/utils/README.md) ! + Known Issues ------- ### Mac OSX troubleshooting diff --git a/utils/CollectSGVarsFromScribus.py b/utils/CollectSGVarsFromScribus.py new file mode 100644 index 0000000..b1fa423 --- /dev/null +++ b/utils/CollectSGVarsFromScribus.py @@ -0,0 +1,35 @@ + +## CSV list for Scribus Generator +## Finds all objects with '%VAR' and lists in a csv (Filename, Variable and type: text/image +## CSV is stored in same folder with the suffix 'Elements' + +## contribution from jvr14115, https://github.com/berteh/ScribusGenerator/issues/116 +## run from within Scribus > Script > run Script + +import os +import re +import scribus + +Edoc = scribus.getDocName() +Edoc = Edoc.replace('.sla', '') +file_name = Edoc + 'Elements.csv' +Edoc = Edoc.replace('Elements.csv', '') +Edoc = re.search(r'(.*)/(.*)', Edoc).group(2) +f = open(file_name, 'w+') +f.write('Template,Element,ElementType') +f.write('\n') +objL = scribus.getAllObjects() +for obj in objL: + objT = scribus.getObjectType(obj) + Evar = '' + if objT == 'ImageFrame': + Etype = 'image' + Evar = scribus.getImageFile(obj) + if objT == 'TextFrame': + Etype = 'text' + Evar = scribus.getAllText(obj) + if '%VAR_' in Evar: + Evar = re.sub('^[^%VAR_]*%VAR_', '', Evar) + Evar = Evar[:-1] + f.write(Edoc + ';"' + Evar + '";' + Etype + '\n') +f.close diff --git a/utils/README.md b/utils/README.md index 405010a..bc090e6 100644 --- a/utils/README.md +++ b/utils/README.md @@ -1,6 +1,19 @@ Various Scripts =========== +Collect variables in template +----------- + +To find all objects with '%VAR' and lists them in a csv (Filename, Variable and type: text/image), +[jvr14115](https://github.com/berteh/ScribusGenerator/issues/116) provided a script you need +to run from within Scribus ``> Script > run Script``, pick ``utils/CollectSGVarsFromScribus.py`` + +Resulting CSV is stored in same folder with the suffix 'Elements'. + +Improvement suggestions are welcome to handle multiple %VAR_%'s in single text frame. + + + Fixes to retro-compatibility issues -----------