Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: mjibson/tnm
base: fd3961086f
...
head fork: mjibson/tnm
compare: bf39cc1a2c
  • 3 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
4 filters.py
View
@@ -66,9 +66,6 @@ def markdown(text):
import utils
return utils.markdown(text)
-def tags(t):
- return ['<span style="font-size: %i%%">%s</span>' %(c * 175 + 25, v) for v, c in t]
-
filters = dict([(i, globals()[i]) for i in [
'date',
'editline',
@@ -83,6 +80,5 @@ def tags(t):
'linkmap',
'markdown',
'rss_date',
- 'tags',
'url',
]])
6 index.yaml
View
@@ -28,3 +28,9 @@ indexes:
- name: f
- name: d
direction: desc
+
+- kind: SiteBlogPost
+ properties:
+ - name: g
+ - name: d
+ direction: desc
14 main.py
View
@@ -877,7 +877,18 @@ def get(self, year=0, month=0):
'months': months,
'nextpage': next,
'posts': posts,
- 'rss': webapp2.uri_for('blog-rss'),
+ 'tags': models.SiteTag.get(),
+ })
+
+class BlogTag(BaseHandler):
+ def get(self, tag):
+ months = models.SiteBlogPost.months()
+
+ self.render('blog.html', {
+ 'archive': months.values,
+ 'months': months,
+ 'posts': models.SiteBlogPost.posts_by_tag(tag),
+ 'tag': tag,
'tags': models.SiteTag.get(),
})
@@ -1110,6 +1121,7 @@ def write_page(pagenum=0):
webapp2.Route(r'/blog', handler='main.Blog'),
webapp2.Route(r'/blog/<link>', handler='main.BlogPost', name='site-blog-post'),
webapp2.Route(r'/blog/<year:\d+>/<month:\d+>', handler='main.Blog', name='site-blog-month'),
+ webapp2.Route(r'/blog/tag/<tag>', handler='main.BlogTag', name='site-blog-tag'),
webapp2.Route(r'/checkout', handler='main.Checkout', name='checkout'),
webapp2.Route(r'/edit', handler='main.Edit', name='edit-home'),
webapp2.Route(r'/edit/<pagename>', handler='main.Edit', name='edit'),
22 models.py
View
@@ -387,11 +387,15 @@ def link_filter(prop, value):
class Tag(ndb.Model):
count = ndb.IntegerProperty('c', indexed=False)
+ MAX_SIZE = 200
+ START = 100
+
@classmethod
def get(cls, parent=None):
- tags = list(cls.query(ancestor=parent))
- m = float(max([i.count for i in tags]))
- return [(i.key.id(), i.count / m) for i in tags if i.count > 0]
+ tags = [i for i in cls.query(ancestor=parent) if i.count]
+ m = max([i.count for i in tags])
+ high = cls.MAX_SIZE / (m - 1) if m > 1 else 0
+ return [(i.key.id(), cls.START + high * (i.count - 1)) for i in tags]
class SiteTag(Tag):
pass
@@ -465,6 +469,12 @@ def posts(cls, year, month, parent=None):
return ndb.get_multi(keys)
@classmethod
+ def posts_by_tag(cls, tag, parent=None):
+ keys = list(cls.query(ancestor=parent).filter(cls.tags == tag).order(
+ -cls.date).iter(keys_only=True))
+ return ndb.get_multi(keys)
+
+ @classmethod
def drafts(cls, parent=None):
return cls.query(ancestor=parent).filter(cls.draft == True).order(-cls.date).iter()
@@ -590,7 +600,11 @@ def update_tags(key):
tis[i] = i.get()
for k, v in tis.items():
- if not v:
+ if p.draft:
+ if key in v.keys:
+ v.keys.remove(key)
+ v.put()
+ elif not v:
m = TagIndex(key=k, keys=[key])
m.put()
tis[k] = m
5 templates/blog-base.html
View
@@ -70,7 +70,10 @@
<div class="widget">
<h3 class="title">Tags</h3>
- {{ tags|tags|join(', ') }}
+ {% for name, size in tags %}
+ <a href="{{ 'site-blog-tag'|url(tag=name) }}" style="font-size: {{ size }}%">{{ name }}</a>
+ {%- if not loop.last %},{% endif %}
+ {% endfor %}
</div>
<div id="archives-2" class="widget widget_archive">
6 templates/blog.html
View
@@ -47,14 +47,14 @@
<a class="carousel-control right" data-slide="next" href="#slider" style="display: inline;">›</a>
</div>
- <h1 id="title">The Next Muse Blog</h1>
+ <h1 id="title">The Next Muse Blog{% if tag %} - {{ tag }}{% endif %}</h1>
<div id="endless" class="staggered clearfix masonry">
<!-- todo: fix this -->
<div id="endless-pad">
- <div style="display: inline-block"><a href="{{ rss }}" class="rss"></a></div>
- <div style="display: inline-block"><a href="{{ rss }}">Subscribe to our RSS feed</a></div>
+ <div style="display: inline-block"><a href="{{ 'blog-rss'|url }}" class="rss"></a></div>
+ <div style="display: inline-block"><a href="{{ 'blog-rss'|url }}">Subscribe to our RSS feed</a></div>
</div>
{% for p in posts %}

No commit comments for this range

Something went wrong with that request. Please try again.