Skip to content

Commit

Permalink
Theme techdoc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
t00m committed Dec 6, 2020
1 parent 0284e03 commit c2ed3cc
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 48 deletions.
109 changes: 71 additions & 38 deletions kb4it/resources/themes/techdoc/logic/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,57 +64,90 @@ def create_page_index(self):
next_events = ""
ROWS_EVENTS = ''
var['rows'] = []
while now <= ldcm:
try:
for doc in self.events_docs[now.year][now.month][now.day]:
row = self.get_doc_event_row(doc)
var['rows'].append(row)
except Exception as error:
pass
delta = timedelta(days=1)
now += delta

while fdnm < ldnm:
try:
for doc in self.events_docs[fdnm.year][fdnm.month][fdnm.day]:
row = self.get_doc_event_row(doc)
var['rows'].append(row)
except Exception as error:
pass
delta = timedelta(days=1)
fdnm += delta

# FIXME: Get number of events to display from theme.conf
max_events = 10
n = 0
for year in self.events_docs:
for month in self.events_docs[year]:
for day in self.events_docs[year][month]:
for doc in self.events_docs[year][month][day]:
try:
if n < max_events:
row = self.get_doc_event_row(doc)
var['rows'].append(row)
n = n + 1
else:
break
except Exception as error:
self.log.error(error)

# ~ while now <= ldcm:
# ~ try:
# ~ for doc in self.events_docs[now.year][now.month][now.day]:
# ~ row = self.get_doc_event_row(doc)
# ~ var['rows'].append(row)
# ~ except Exception as error:
# ~ pass
# ~ delta = timedelta(days=1)
# ~ now += delta

# ~ while fdnm < ldnm:
# ~ try:
# ~ for doc in self.events_docs[fdnm.year][fdnm.month][fdnm.day]:
# ~ row = self.get_doc_event_row(doc)
# ~ var['rows'].append(row)
# ~ except Exception as error:
# ~ pass
# ~ delta = timedelta(days=1)
# ~ fdnm += delta

#FIXME: Get repository title from theme.conf
var['title'] = 'My KB4IT Repostiroy'
var['timestamp'] = timestamp.ctime()
var['calendar_trimester'] = trimester
var['table_trimester'] = TPL_TABLE_EVENTS.render(var=var)

self.distribute('index', TPL_INDEX.render(var=var))


def get_doc_event_row(self, doc):
"""Get card for a given doc"""
row = {}
LINK = self.template('LINK')
title = self.srvdtb.get_values(doc, 'Title')[0]
tooltip ="%s" % (title)
link = {}
link['class'] = "uk-link-heading uk-text-meta"

# Date
row['timestamp'] = self.srvdtb.get_doc_timestamp(doc)

# Team
team = self.srvdtb.get_values(doc, 'Team')[0]
link['url'] = "Team_%s.html" % valid_filename(team)
link['title'] = team
row['team'] = LINK.render(var=link)

# Title
title = self.srvdtb.get_values(doc, 'Title')[0]
link['url'] = "%s.html" % valid_filename(doc).replace('.adoc', '')
link['title'] = title
row['title'] = LINK.render(var=link)

# Category
category = self.srvdtb.get_values(doc, 'Category')[0]
link['url'] = "Category_%s.html" % valid_filename(category)
link['title'] = category
row['category'] = LINK.render(var=link)

# Scope
scope = self.srvdtb.get_values(doc, 'Scope')[0]
team = self.srvdtb.get_values(doc, 'Team')[0]
status = self.srvdtb.get_values(doc, 'Status')[0]

timestamp = self.srvdtb.get_doc_timestamp(doc)
link_team = LINK % ("uk-link-heading uk-text-meta", "Team_%s.html" % valid_filename(team), '', team)
link_title = LINK % ("uk-link-heading uk-text-meta", "%s.html" % valid_filename(doc).replace('.adoc', ''), '', title)
link_category = LINK % ("uk-link-heading uk-text-meta", "Category_%s.html" % valid_filename(category), '', category)
link_status = LINK % ("uk-link-heading uk-text-meta", "Status_%s.html" % valid_filename(status), '', status)
link_scope = LINK % ("uk-link-heading uk-text-meta", "Scope_%s.html" % valid_filename(scope), '', scope)

row['timestamp'] = timestamp
row['team'] = link_team
row['title'] = link_title
row['category'] = link_category
row['scope'] = link_scope
row['status'] = link_status
link['url'] = "Scope_%s.html" % valid_filename(scope)
link['title'] = scope
row['scope'] = LINK.render(var=link)

# Status
# ~ status = self.srvdtb.get_values(doc, 'Status')[0]
# ~ row['status'] = link_status

return row

def build_events(self, doclist):
Expand Down
20 changes: 10 additions & 10 deletions kb4it/resources/themes/techdoc/templates/TABLE_EVENT.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<caption></caption>
<thead>
<tr>
<th class="uk-text-bold">Date</th>
<th class="uk-text-bold">Team</th>
<th class="uk-text-bold">Title</th>
<th class="uk-text-bold">Category</th>
<th class="uk-text-bold">Scope</th>
<th class="uk-text-bold uk-text-primary">Date</th>
<th class="uk-text-bold uk-text-primary">Team</th>
<th class="uk-text-bold uk-text-primary">Title</th>
<th class="uk-text-bold uk-text-primary">Category</th>
<th class="uk-text-bold uk-text-primary">Scope</th>
</tr>
</thead>
<tfoot>
Expand All @@ -17,11 +17,11 @@
<tbody>
% for row in var['rows']:
<tr>
<td>${row['timestamp']}</td>
<td>${row['team']}</td>
<td>${row['title']}</td>
<td>${row['category']}</td>
<td>${row['scope']}</td>
<td class="uk-text-meta">${row['timestamp']}</td>
<td class="uk-text-meta">${row['team']}</td>
<td class="uk-text-meta">${row['title']}</td>
<td class="uk-text-meta">${row['category']}</td>
<td class="uk-text-meta">${row['scope']}</td>
</tr>
% endfor
</tbody>
Expand Down

0 comments on commit c2ed3cc

Please sign in to comment.