diff --git a/functions.py b/functions.py index ce6d4a2..e376e46 100644 --- a/functions.py +++ b/functions.py @@ -14,7 +14,7 @@ def pandoc(pwd, content, format_in, format_out): # tmp files mw_tmp_fn = os.path.join(pwd, '.mediawiki_content') - html_tmp_fn = os.path.join(pwd, '.html_content') # TODO: join with pw + html_tmp_fn = os.path.join(pwd, '.html_content') for fn in [mw_tmp_fn, html_tmp_fn ]: if os.path.isfile(fn) is False: os.mknod(fn) # create them if not in dir diff --git a/helper-upload_imgs_dir.sh b/helper-upload_imgs_dir.sh index c2e7431..81b663e 100755 --- a/helper-upload_imgs_dir.sh +++ b/helper-upload_imgs_dir.sh @@ -9,7 +9,10 @@ python3 upload_imgs_dir.py \ --event 'The ARTEX Strike' \ --topic 'Workers rights' \ --language 'English' \ ---dir '/full/path/to/2020_bantayog/Folder name' # --dry +--dir '/full/path/to/2020_bantayog/Folder name' \ + + +# --dry # Note: # * Add this values to you upload specific upload. @@ -18,8 +21,3 @@ python3 upload_imgs_dir.py \ # * \ allow you to continue the command of a different line # # Get help: python3 upload_imgs_dir.py --help - - - - - diff --git a/query2html.py b/query2html.py index 457f5f5..0d51119 100644 --- a/query2html.py +++ b/query2html.py @@ -25,6 +25,7 @@ p.add_argument("--order", "-o", metavar='', help='Order of sorting conditions. Should same amount as the --sort properties') p.add_argument('--limit', '-l', help='(optional) Limit the number of returned ' 'items') +# TODO: GET limit to work.Perhaps with a site.raw_api method p.add_argument('--dry', '-d', action='store_true', help='dry-run: will only show the query but not run it') @@ -95,6 +96,11 @@ for answer in site.ask(query): pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html') img_local = os.path.join(imgdir, img_info.get('filename')) + # Todo: Create list of all images from document + # TODO: join document_part + document + # TODO: look into the template structure of images : columns and rows + + # RENDER document part document_part_html = document_part_template.render( printout_dict=printout_dict, @@ -118,7 +124,6 @@ for answer in site.ask(query): all_document_parts = '' # Reset all_document_parts # add info to documentslist for index creation - # TODO: possibly needs to be a SortedDict documentslist.append({'file': htmlpage_fn, 'title': printout_dict.get('Title'), 'date': printout_dict.get('Date'), diff --git a/sandbox/jinja_tutorial.py b/sandbox/jinja_tutorial.py new file mode 100644 index 0000000..10eb21c --- /dev/null +++ b/sandbox/jinja_tutorial.py @@ -0,0 +1,15 @@ +import os +from jinja2 import Template + +wd = os.path.dirname(os.path.abspath(__file__)) # working directory + +# read template files +with open(os.path.join(wd, '../templates/scatch.html')) as document_html: + template = Template(document_html.read()) + +imgs_list = ['images/01.jpg', 'images/02.jpg', 'images/03.jpg'] + +template_render = template.render(title=':) Hello Sandra', + imgs=imgs_list + ) +print(template_render) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index efe90e2..8e45d6e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,7 @@ {{title}} -

Results from query:
{{query}}

+

Resultsss from query:
{{query}}