• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Revisionc3595fcc6a027b6137547577286749981844abc8 (tree)
Zeit2012-06-12 00:47:42
AutorDave Brondsema <dbrondsema@geek...>
CommiterDave Brondsema

Log Message

[#4254] remove source/hash logic from blog post slugs, since they were causing view/edit links not to work. Moreover, they aren't really necessary and make the URL uglier

Ändern Zusammenfassung

Diff

--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -182,7 +182,7 @@ class RssFeedsCommand(base.BlogCommand):
182182
183183 updated = datetime.utcfromtimestamp(mktime(e.updated_parsed))
184184
185- base_slug = BM.BlogPost.make_base_slug(title, updated, feed_url)
185+ base_slug = BM.BlogPost.make_base_slug(title, updated)
186186 b_count = BM.BlogPost.query.find(dict(slug=base_slug, app_config_id=appid)).count()
187187 if b_count == 0:
188188 post = BM.BlogPost(title=title, text=content, timestamp=updated,
@@ -190,7 +190,7 @@ class RssFeedsCommand(base.BlogCommand):
190190 tool_version={'blog': version.__version__},
191191 state='published')
192192 post.neighborhood_id=c.project.neighborhood_id
193- post.make_slug(source=feed_url)
193+ post.make_slug()
194194 post.commit()
195195
196196 session(BM.BlogPost).flush()
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -139,26 +139,17 @@ class BlogPost(M.VersionedArtifact):
139139 return '%s@%s%s' % (self.title.replace('/', '.'), domain, config.common_suffix)
140140
141141 @staticmethod
142- def make_base_slug(title, timestamp, source = None):
142+ def make_base_slug(title, timestamp):
143143 slugsafe = ''.join(
144144 ch.lower()
145145 for ch in title.replace(' ', '-')
146146 if ch.isalnum() or ch == '-')
147- if source is None:
148- base = '%s/%s' % (
147+ return '%s/%s' % (
149148 timestamp.strftime('%Y/%m'),
150149 slugsafe)
151- else:
152- m = hashlib.md5()
153- m.update(source)
154- link_hash_key = m.hexdigest()[:16]
155- base = '%s/%s/%s' % (
156- timestamp.strftime('%Y/%m'),
157- link_hash_key, slugsafe)
158- return base
159150
160- def make_slug(self, source = None):
161- base = BlogPost.make_base_slug(self.title, self.timestamp, source)
151+ def make_slug(self):
152+ base = BlogPost.make_base_slug(self.title, self.timestamp)
162153 self.slug = base
163154 while True:
164155 try:
@@ -166,7 +157,6 @@ class BlogPost(M.VersionedArtifact):
166157 return self.slug
167158 except DuplicateKeyError:
168159 self.slug = base + '-%.3d' % randint(0,999)
169- return self.slug
170160
171161 def url(self):
172162 return self.app.url + self.slug + '/'