master
Slayr 5 years ago
commit 51e62b6753

@ -14,7 +14,7 @@ def pandoc(pwd, content, format_in, format_out):
# tmp files # tmp files
mw_tmp_fn = os.path.join(pwd, '.mediawiki_content') 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 ]: for fn in [mw_tmp_fn, html_tmp_fn ]:
if os.path.isfile(fn) is False: if os.path.isfile(fn) is False:
os.mknod(fn) # create them if not in dir os.mknod(fn) # create them if not in dir

@ -9,7 +9,10 @@ python3 upload_imgs_dir.py \
--event 'The ARTEX Strike' \ --event 'The ARTEX Strike' \
--topic 'Workers rights' \ --topic 'Workers rights' \
--language 'English' \ --language 'English' \
--dir '/full/path/to/2020_bantayog/Folder name' # --dry --dir '/full/path/to/2020_bantayog/Folder name' \
# --dry
# Note: # Note:
# * Add this values to you upload specific upload. # * 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 # * \ allow you to continue the command of a different line
# #
# Get help: python3 upload_imgs_dir.py --help # Get help: python3 upload_imgs_dir.py --help

@ -25,6 +25,7 @@ p.add_argument("--order", "-o", metavar='',
help='Order of sorting conditions. Should same amount as the --sort properties') help='Order of sorting conditions. Should same amount as the --sort properties')
p.add_argument('--limit', '-l', help='(optional) Limit the number of returned ' p.add_argument('--limit', '-l', help='(optional) Limit the number of returned '
'items') 'items')
# TODO: GET limit to work.Perhaps with a site.raw_api method
p.add_argument('--dry', '-d', action='store_true', p.add_argument('--dry', '-d', action='store_true',
help='dry-run: will only show the query but not run it') 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') pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
img_local = os.path.join(imgdir, img_info.get('filename')) 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 # RENDER document part
document_part_html = document_part_template.render( document_part_html = document_part_template.render(
printout_dict=printout_dict, printout_dict=printout_dict,
@ -118,7 +124,6 @@ for answer in site.ask(query):
all_document_parts = '' # Reset all_document_parts all_document_parts = '' # Reset all_document_parts
# add info to documentslist for index creation # add info to documentslist for index creation
# TODO: possibly needs to be a SortedDict
documentslist.append({'file': htmlpage_fn, documentslist.append({'file': htmlpage_fn,
'title': printout_dict.get('Title'), 'title': printout_dict.get('Title'),
'date': printout_dict.get('Date'), 'date': printout_dict.get('Date'),

@ -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)

@ -5,7 +5,7 @@
<title>{{title}}</title> <title>{{title}}</title>
</head> </head>
<body> <body>
<h3>Results from query:<br/><code>{{query}}</code></h3> <h3>Resultsss from query:<br/><code>{{query}}</code></h3>
<ul> <ul>
{% for doc in documentslist %} {% for doc in documentslist %}
<li><a href="./{{ doc['file'] }}">{{ doc['title'][0] }}</a> <li><a href="./{{ doc['file'] }}">{{ doc['title'][0] }}</a>

@ -0,0 +1,13 @@
<h1>{{ title|upper }}</h1>
<div class="row">
<div class="column">
{% for img in imgs %}
<img src="{{img}}" style="width:100%">
{% endfor %}
</div>
</div>
{{imgs}}
Loading…
Cancel
Save