Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

набросаны теги #277

Closed
wants to merge 1 commit into from

2 participants

@yanwork

блок с тегами появляется на странице архив после применения команды
blogit -wf

блок большой (1Мб) и [пока] не очень красивый, но довольно полезный (для нелюбителей грепа)

можно причесать

@bobuk
Owner

Отказался от старой верстки и старого скрипта. Простите все меня пожалуйста!

@bobuk bobuk closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 30, 2012
  1. @yanwork

    initial draft

    yanwork authored
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 1 deletion.
  1. +18 −1 blogit
  2. +11 −0 source/templates/archive.mustache
View
19 blogit
@@ -67,6 +67,16 @@ def makeHtml(inbound):
res = re.sub('\{([a-zA-Z0-9\*]+)\}', tags_cludge, res)
return res
+def getTags(entry):
+ tags = {}
+ for line in entry.content.split('\n'):
+ line = line.strip()
+ tagsFinded = re.findall(" \#([a-zA-Z0-9\*]+)", line) + re.findall("\{([a-zA-Z0-9\*]+)\}", line)
+ for tag in tagsFinded:
+ tags[tag] = tags.get(tag,[])
+ tags[tag].append({'page' : entry.page, 'line' : line})
+ return tags
+
def extract_numbers(s):
s = s.replace('.md', '')
num = ''.join((x for x in s if x.isdigit()))
@@ -164,6 +174,7 @@ class MarkDownEntry(Entry):
title, rest = self.content.split('\n', 1)
self.title = title
self.content = rest
+ self.tags = getTags(self)
self.content = makeHtml(self.content)
self.result = os.path.join(config['local']['results']['posts'],
self.page, 'index.html')
@@ -203,7 +214,8 @@ class Archive:
'conf': config,
'title': 'Archive',
'items': items,
- 'permalink': config['site'] + '/archive'
+ 'permalink': config['site'] + '/archive',
+ 'tags': self.idx['tags'].values()
})
with saveto(self.results) as fl:
fl.write(res)
@@ -465,6 +477,7 @@ def regen(wipe=False, force=False, noindex=False, andsync=False, sections=False)
"""regenerate index and all pages"""
cache = Index(ro=True)
with Index() as idx:
+ tags = {}
if wipe:
idx['idx'] = []
cache['idx'] = []
@@ -472,6 +485,10 @@ def regen(wipe=False, force=False, noindex=False, andsync=False, sections=False)
entry = gen_page(page=item, force=force, index=cache)
if entry:
put_to_index(index=idx, entry=entry)
+ for tag in entry.tags:
+ tags[tag] = tags.get(tag, {'name': tag, 'hits': []})
+ tags[tag]['hits'] = tags[tag]['hits'] + entry.tags[tag]
+ idx['tags'] = tags
if sections:
for item in os.listdir(config['local']['section']):
entry = gen_section(page=item)
View
11 source/templates/archive.mustache
@@ -88,6 +88,17 @@
<li><a href="{{ fname }}">{{ subtitle }}</a></li>
{{/items }}
</ul>
+ <h2>Tags</h2>
+ <ul>
+ {{#tags}}
+ <li>{{name}}</li>
+ <ul>
+ {{#hits}}
+ <li>{{page}} {{line}}</li>
+ {{/hits}}
+ </ul>
+ {{/tags}}
+ </ul>
</article>
<hr>
Something went wrong with that request. Please try again.