allura
Revision | c3595fcc6a027b6137547577286749981844abc8 (tree) |
---|---|
Zeit | 2012-06-12 00:47:42 |
Autor | Dave Brondsema <dbrondsema@geek...> |
Commiter | Dave Brondsema |
[#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
@@ -182,7 +182,7 @@ class RssFeedsCommand(base.BlogCommand): | ||
182 | 182 | |
183 | 183 | updated = datetime.utcfromtimestamp(mktime(e.updated_parsed)) |
184 | 184 | |
185 | - base_slug = BM.BlogPost.make_base_slug(title, updated, feed_url) | |
185 | + base_slug = BM.BlogPost.make_base_slug(title, updated) | |
186 | 186 | b_count = BM.BlogPost.query.find(dict(slug=base_slug, app_config_id=appid)).count() |
187 | 187 | if b_count == 0: |
188 | 188 | post = BM.BlogPost(title=title, text=content, timestamp=updated, |
@@ -190,7 +190,7 @@ class RssFeedsCommand(base.BlogCommand): | ||
190 | 190 | tool_version={'blog': version.__version__}, |
191 | 191 | state='published') |
192 | 192 | post.neighborhood_id=c.project.neighborhood_id |
193 | - post.make_slug(source=feed_url) | |
193 | + post.make_slug() | |
194 | 194 | post.commit() |
195 | 195 | |
196 | 196 | session(BM.BlogPost).flush() |
@@ -139,26 +139,17 @@ class BlogPost(M.VersionedArtifact): | ||
139 | 139 | return '%s@%s%s' % (self.title.replace('/', '.'), domain, config.common_suffix) |
140 | 140 | |
141 | 141 | @staticmethod |
142 | - def make_base_slug(title, timestamp, source = None): | |
142 | + def make_base_slug(title, timestamp): | |
143 | 143 | slugsafe = ''.join( |
144 | 144 | ch.lower() |
145 | 145 | for ch in title.replace(' ', '-') |
146 | 146 | if ch.isalnum() or ch == '-') |
147 | - if source is None: | |
148 | - base = '%s/%s' % ( | |
147 | + return '%s/%s' % ( | |
149 | 148 | timestamp.strftime('%Y/%m'), |
150 | 149 | 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 | |
159 | 150 | |
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) | |
162 | 153 | self.slug = base |
163 | 154 | while True: |
164 | 155 | try: |
@@ -166,7 +157,6 @@ class BlogPost(M.VersionedArtifact): | ||
166 | 157 | return self.slug |
167 | 158 | except DuplicateKeyError: |
168 | 159 | self.slug = base + '-%.3d' % randint(0,999) |
169 | - return self.slug | |
170 | 160 | |
171 | 161 | def url(self): |
172 | 162 | return self.app.url + self.slug + '/' |