-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tag indexing #144
base: master
Are you sure you want to change the base?
Fix tag indexing #144
Conversation
That's great, thanks! Does slugify() also work with Windows? |
I think it should but I don’t have access to a testing environment. Can fix up the tuple thing tomorrow but I was trying to get it working quickly 😅 |
tumblr_backup.py
Outdated
@@ -414,7 +429,8 @@ def save_tag_index(self): | |||
mkdir(path_to(tag_index_dir)) | |||
self.fixup_media_links() | |||
tag_index = [self.blog.header('Tag index', 'tag-index', self.blog.title, True), '<ul>'] | |||
for tag, index in sorted(self.tags.items(), key=lambda kv: kv[1].name): | |||
for _, index in sorted(self.tags.items(), key=lambda kv: kv[1].name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tags.values()
to get just the values instead of tuples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I’m aware of this.
As a sidenote, I didn't want to add an additional dependency but unicode-slugify also handles if you want to slug with non-ascii characters (which I'm doing for my own archive, since I have plenty of CJK tags) |
It seems like tumblr tags are a wonderful example of diverse user input that's always trying to outsmart the slug code. CJK tags, tags with slashes, tags with all kinds of odd unicode, emoji, multiple tags condensing down to one slug (whose sets aren't identical, so the rendered HTML is incomplete)... Assuming you don't mind too much what the folder name is --if your use of the backup is mostly using the rendered HTML-- this approach seems to work for me for various weird tags (haven't found a broken or empty link yet, though there are thousands of tags in my backup):
I'm also pretty sure hashlib is part of the standard library, so no additional module install is needed. |
/
in it