Skip to content

Commit

Permalink
Fix issue #90
Browse files Browse the repository at this point in the history
  • Loading branch information
t00m committed Mar 13, 2021
1 parent 8a8ca9d commit 5aa3d7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion kb4it/core/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
code\nas you want"
APP['copyright'] = "Copyright \xa9 2019 Tomás Vírseda"
APP['desc'] = ""
APP['version'] = '0.7.8.1'
APP['version'] = '0.7.8.2'
APP['author'] = 'Tomás Vírseda'
APP['author_email'] = 'tomasvirseda@gmail.com'
APP['documenters'] = ["Tomás Vírseda <tomasvirseda@gmail.com>"]
Expand Down
3 changes: 3 additions & 0 deletions kb4it/services/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ def stage_04_processing(self):
sorted_docs = self.srvdtb.sort_by_date(docs)
basename = "%s_%s" % (valid_filename(key), valid_filename(value))
pagination = {}
pagination['key'] = key
pagination['value'] = value
pagination['basename'] = basename
pagination['doclist'] = sorted_docs
pagination['title'] = None
Expand Down Expand Up @@ -727,6 +729,7 @@ def run(self):
self.stage_02_get_source_documents()
self.stage_03_preprocessing()
self.stage_04_processing()
self.srvthm.generate_pages()
self.stage_05_compilation()
self.stage_07_clean_target()
self.stage_08_refresh_target()
Expand Down
28 changes: 18 additions & 10 deletions kb4it/services/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,16 @@ def build_pagination(self, pagination):
Create a page with documents.
If amount of documents is greater than 100, split it in several pages
"""
# ~ print("PG. TPL: %s" % pagination['template'])
TPL_PG_HEAD = self.template(pagination['template'])
var = {}

# Pagination title
# Custom pagination title por key pages
try:
var['title_key'] = pagination['key']
var['title_value'] = pagination['value']
except Exception as error:
pass

if pagination['title'] is None:
var['title'] = pagination['basename'].replace('_', ' ')
else:
Expand Down Expand Up @@ -272,13 +277,11 @@ def build_pagination(self, pagination):
k = math.ceil(var['num_rel_docs'] / total_pages)
var['k'] = k
var['total'] = total_pages

var['pg-head-items'] = ''
for current_page in range(total_pages):
# ~ PAGINATION = self.template('PAGINATION_START')
page = {}
page['num'] = current_page
# ~ page['pg-head-items'] = ''
var['pg-head-items'] = ''
if total_pages > 0:
for i in range(total_pages):
start = k * i # lower limit
Expand Down Expand Up @@ -310,7 +313,6 @@ def build_pagination(self, pagination):
page['page_count_docs'] = var['num_rel_docs']
page['page_link'] = PAGE.replace('adoc', 'html')
var['pg-head-items'] += TPL_PAGINATION_PAGE_INACTIVE.render(var=page) #i, start, end, num_rel_docs, PAGE.replace('adoc', 'html'), i)
# ~ PAGINATION += self.template('PAGINATION_END')

if current_page == 0:
name = "%s" % pagination['basename']
Expand Down Expand Up @@ -428,6 +430,10 @@ def generate_sources(self):
"""Custom themes can use this method to generate source documents"""
pass

def generate_pages(self):
"""Custom themes can use this method to generate final pages"""
pass

def create_page_help(self):
"""
Create help page.
Expand Down Expand Up @@ -580,7 +586,7 @@ def get_doc_card(self, doc):
TPL_DOC_CARD_CLASS = self.template('CARD_DOC_CLASS')
LINK = self.template('LINK')

title = self.srvdtb.get_values(doc, 'Title')[0]
title = self.srvdtb.get_values(doc, 'Title')[0]
category = self.srvdtb.get_values(doc, 'Category')[0]
scope = self.srvdtb.get_values(doc, 'Scope')[0]
var['category'] = category
Expand All @@ -591,7 +597,10 @@ def get_doc_card(self, doc):
link['class'] = TPL_DOC_CARD_CLASS.render()
link['url'] = valid_filename(doc).replace('.adoc', '.html')
link['title'] = title
var['link'] = link
var['link_rendered'] = LINK.render(var=link)
var['title'] = LINK.render(var=link)
var['title_nolink'] = title
# ~ link_title = LINK.render(var=link)
if len(var['category']) > 0 and len(var['scope']) > 0:
cat = {}
Expand All @@ -613,7 +622,6 @@ def get_doc_card(self, doc):
var['fuzzy_date'] = fuzzy_date_from_timestamp(var['timestamp'])
var['tooltip'] = title
DOC_CARD = TPL_DOC_CARD.render(var=var)
# ~ self.log.error(DOC_CARD)
return DOC_CARD

def get_labels(self, values):
Expand Down Expand Up @@ -648,8 +656,8 @@ def create_page_about_theme(self):
TPL_PAGE_ABOUT_THEME = self.template('PAGE_ABOUT_THEME')
var = {}
var['theme'] = {}
theme = self.srvapp.get_theme_properties()

theme = self.srvapp.get_theme_properties()
for key in theme:
value = theme[key]
try:
Expand Down

0 comments on commit 5aa3d7b

Please sign in to comment.