Skip to content

Commit

Permalink
Fixed #76: renamed docs_parsed to docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaph committed May 18, 2015
1 parent 64d097a commit 2713d85
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions logya/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def init_env(self):
raise Exception('base_url not set in site config.')

# A dictionary of parsed documents indexed by resource paths.
self.docs_parsed = {}
self.docs = {}

# A dictionary of document collections.
self.index = {}
Expand Down Expand Up @@ -165,9 +165,9 @@ def build_index(self, mode=None):
for doc in DocReader(self.dir_content).parsed:
url = doc['url']
# Warn user about duplicate URLs when not in serve mode.
if 'serve' != mode and url in self.docs_parsed:
if 'serve' != mode and url in self.docs:
print(msg_duplicate.format(url))
self.docs_parsed[url] = doc
self.docs[url] = doc
self.update_index(doc)

# Sort document collections by descending docs creation dates.
Expand Down Expand Up @@ -203,7 +203,7 @@ def write_index(self, url, collection):

check_doc_url = '/{}'.format(path.join(url, self.index_filename))
# make sure there exists no document at the index url
if check_doc_url not in self.docs_parsed:
if check_doc_url not in self.docs:
# Ugly fix for issue #32: delete description var. This is called
# for every index, instead of once for all, because write_index is
# called in serve mode. Also there may remain other vars causing
Expand Down
4 changes: 2 additions & 2 deletions logya/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def __init__(self, **kwargs):
self.build_index()

self.info('Write documents')
for doc in list(self.docs_parsed.values()):
for doc in list(self.docs.values()):
self.writer.write(doc, self.get_doc_template(doc))
self.info(
'Written {:d} documents to deploy directory'
.format(len(self.docs_parsed)))
.format(len(self.docs)))

self.info('Write index files')
self.write_index_files()
Expand Down
8 changes: 4 additions & 4 deletions logya/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ def refresh_resource(self, path):

# Try to get doc at path, regenerate it and return.
doc = None
if path in self.docs_parsed:
doc = self.docs_parsed[path]
if path in self.docs:
doc = self.docs[path]
else:
# If a path like /index.html is requested also try to find /.
alt_path = os.path.dirname(path)
if not alt_path.endswith('/'):
alt_path = '{}/'.format(alt_path)
if alt_path in self.docs_parsed:
doc = self.docs_parsed[alt_path]
if alt_path in self.docs:
doc = self.docs[alt_path]

if doc:
docwriter = DocWriter(self.dir_deploy, self.template)
Expand Down
2 changes: 1 addition & 1 deletion logya/sites/starter/scripts/site_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logya.build_index()

site_index = {}
for url, doc in logya.docs_parsed.items():
for url, doc in logya.docs.items():
del doc['body']
site_index[url] = doc

Expand Down
2 changes: 1 addition & 1 deletion logya/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def filesource(logya_inst, name, lines=None):


def get_doc(logya_inst, url):
return logya_inst.docs_parsed.get(url)
return logya_inst.docs.get(url)


class Template():
Expand Down

0 comments on commit 2713d85

Please sign in to comment.