From afbf2a5343512eacc459ea053fe721a5b6c5363e Mon Sep 17 00:00:00 2001 From: renpj Date: Fri, 10 Nov 2017 09:34:03 -0800 Subject: [PATCH 1/5] modified: .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1e3586ee1..3a4f1010f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ django-apps-src docs/build demo/demo.db* django_blog_zinnia.egg-info/ +build From 6d0bf7090fe70759d0e09b0222695a2fb5cfdac6 Mon Sep 17 00:00:00 2001 From: renpj Date: Mon, 13 Nov 2017 04:50:27 -0800 Subject: [PATCH 2/5] Compatible with Open Live Writer and non-ASCII charaters --- setup.py | 3 ++- zinnia/feeds.py | 2 +- zinnia/models_bases/entry.py | 2 +- zinnia/templating.py | 2 +- zinnia/views/comments.py | 2 +- zinnia/views/quick_entry.py | 2 +- zinnia/views/tags.py | 2 +- zinnia/xmlrpc/__init__.py | 6 +++++- zinnia/xmlrpc/metaweblog.py | 20 ++++++++++++++++---- 9 files changed, 29 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index a6740d9f9..3447b5abe 100644 --- a/setup.py +++ b/setup.py @@ -41,5 +41,6 @@ 'pillow>=2.0.0', 'pyparsing>=2.0.3', 'pytz>=2014.10', - 'regex>=2016.3.2'] + 'regex>=2016.3.2', + 'python-slugify',] # compatible with non ASCII charaters ) diff --git a/zinnia/feeds.py b/zinnia/feeds.py index c2709f226..7e7f56c09 100644 --- a/zinnia/feeds.py +++ b/zinnia/feeds.py @@ -13,7 +13,7 @@ from django.contrib.syndication.views import Feed from django.core.exceptions import ObjectDoesNotExist from django.shortcuts import get_object_or_404 -from django.template.defaultfilters import slugify +from slugify import slugify from django.urls import NoReverseMatch from django.urls import reverse from django.utils.encoding import smart_text diff --git a/zinnia/models_bases/entry.py b/zinnia/models_bases/entry.py index 52a3252bc..e84c6a026 100644 --- a/zinnia/models_bases/entry.py +++ b/zinnia/models_bases/entry.py @@ -4,7 +4,7 @@ from django.contrib.sites.models import Site from django.db import models from django.db.models import Q -from django.template.defaultfilters import slugify +from slugify import slugify from django.urls import reverse from django.utils import timezone from django.utils.encoding import python_2_unicode_compatible diff --git a/zinnia/templating.py b/zinnia/templating.py index 74e78c046..ffb3654e0 100644 --- a/zinnia/templating.py +++ b/zinnia/templating.py @@ -1,7 +1,7 @@ """Templates module for Zinnia""" import os -from django.template.defaultfilters import slugify +from slugify import slugify def append_position(path, position, separator=''): diff --git a/zinnia/views/comments.py b/zinnia/views/comments.py index 73a144d81..fd24fb65e 100644 --- a/zinnia/views/comments.py +++ b/zinnia/views/comments.py @@ -1,7 +1,7 @@ """Views for Zinnia comments""" from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponsePermanentRedirect -from django.template.defaultfilters import slugify +from slugify import slugify from django.views.generic.base import TemplateResponseMixin from django.views.generic.base import View diff --git a/zinnia/views/quick_entry.py b/zinnia/views/quick_entry.py index 0c7c0307b..d9e657f6b 100644 --- a/zinnia/views/quick_entry.py +++ b/zinnia/views/quick_entry.py @@ -8,7 +8,7 @@ from django.contrib.auth.decorators import permission_required from django.contrib.sites.models import Site from django.shortcuts import redirect -from django.template.defaultfilters import slugify +from slugify import slugify from django.urls import reverse from django.utils import timezone from django.utils.decorators import method_decorator diff --git a/zinnia/views/tags.py b/zinnia/views/tags.py index 653b0ffa2..ff27763ae 100644 --- a/zinnia/views/tags.py +++ b/zinnia/views/tags.py @@ -1,6 +1,6 @@ """Views for Zinnia tags""" from django.http import Http404 -from django.template.defaultfilters import slugify +from slugify import slugify from django.utils.translation import ugettext as _ from django.views.generic.list import BaseListView from django.views.generic.list import ListView diff --git a/zinnia/xmlrpc/__init__.py b/zinnia/xmlrpc/__init__.py index 874595e61..9feaacfc5 100644 --- a/zinnia/xmlrpc/__init__.py +++ b/zinnia/xmlrpc/__init__.py @@ -18,10 +18,14 @@ 'wp.getAuthors'), ('zinnia.xmlrpc.metaweblog.get_tags', 'wp.getTags'), + ('zinnia.xmlrpc.metaweblog.get_categories', + 'wp.getCategories'), ('zinnia.xmlrpc.metaweblog.get_categories', 'metaWeblog.getCategories'), ('zinnia.xmlrpc.metaweblog.new_category', - 'wp.newCategory'), + 'wp.newCategory'), + ('zinnia.xmlrpc.metaweblog.set_categories', + 'mt.setPostCategories'), ('zinnia.xmlrpc.metaweblog.get_recent_posts', 'metaWeblog.getRecentPosts'), ('zinnia.xmlrpc.metaweblog.get_post', diff --git a/zinnia/xmlrpc/metaweblog.py b/zinnia/xmlrpc/metaweblog.py index cfea22745..25ca43e1e 100644 --- a/zinnia/xmlrpc/metaweblog.py +++ b/zinnia/xmlrpc/metaweblog.py @@ -11,7 +11,7 @@ from django.contrib.sites.models import Site from django.core.files.base import ContentFile from django.core.files.storage import default_storage -from django.template.defaultfilters import slugify +from slugify import slugify # compatible with non-ASCII characters from django.urls import reverse from django.utils import six from django.utils import timezone @@ -204,7 +204,7 @@ def delete_post(apikey, post_id, username, password, publish): entry.delete() return True - + @xmlrpc_func(returns='struct', args=['string', 'string', 'string']) def get_post(post_id, username, password): """ @@ -262,8 +262,9 @@ def new_category(blog_id, username, password, category_struct): """ authenticate(username, password, 'zinnia.add_category') category_dict = {'title': category_struct['name'], - 'description': category_struct['description'], - 'slug': category_struct['slug']} +# 'description': category_struct['description'], # open live writer doesn't support this key +# 'slug': category_struct['slug'] # open live writer doesn't support this key + } if int(category_struct['parent_id']): category_dict['parent'] = Category.objects.get( pk=category_struct['parent_id']) @@ -271,6 +272,17 @@ def new_category(blog_id, username, password, category_struct): return category.pk + +@xmlrpc_func(returns='boolean', args=['string', 'string', 'string', 'struct']) +def set_categories(postid, username, password, categories): + """ + mt.setPostCategories(postid, username, password, categories) + => boolean + """ + # This is useless 'cause category already set by new_post(). + # Just for the compatability with open live writer + return True + @xmlrpc_func(returns='string', args=['string', 'string', 'string', 'struct', 'boolean']) From a25b76be1b92cca60c7710c15c09ab2e551fe3d5 Mon Sep 17 00:00:00 2001 From: renpj Date: Tue, 14 Nov 2017 17:55:03 -0800 Subject: [PATCH 3/5] update metaweblog, fix one bug --- zinnia/xmlrpc/metaweblog.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zinnia/xmlrpc/metaweblog.py b/zinnia/xmlrpc/metaweblog.py index 25ca43e1e..97e4e0108 100644 --- a/zinnia/xmlrpc/metaweblog.py +++ b/zinnia/xmlrpc/metaweblog.py @@ -261,10 +261,16 @@ def new_category(blog_id, username, password, category_struct): => category_id """ authenticate(username, password, 'zinnia.add_category') - category_dict = {'title': category_struct['name'], -# 'description': category_struct['description'], # open live writer doesn't support this key -# 'slug': category_struct['slug'] # open live writer doesn't support this key - } + category_dict = { + 'title': category_struct['name'], + 'slug': slugify(category_struct['name']), + } + if category_struct.has_key('description'): + if category_struct['description']: + category_dict['description'] = category_struct['description'] + if category_struct.has_key('slug'): + if category_struct['slug']: + category_dict['slug'] = category_struct['slug'] if int(category_struct['parent_id']): category_dict['parent'] = Category.objects.get( pk=category_struct['parent_id']) From 5307d8bd4547263ff627cd7dc15e95df0bae0a75 Mon Sep 17 00:00:00 2001 From: renpj Date: Wed, 7 Feb 2018 23:45:55 -0800 Subject: [PATCH 4/5] modified: README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index e1212837f..905163e8a 100644 --- a/README.rst +++ b/README.rst @@ -61,12 +61,12 @@ Take a look at the online demo at: http://demo.django-blog-zinnia.com/ or you can visit these websites who use Zinnia. * `Fantomas' side`_ -* `Ubuntu's developers blog`_ * `Vidzor Studio LLC`_ * `Bookshadow`_ * `Future Proof Games`_ * `Programeria`_ * `Tihomir Blajev Blog`_ +* `Branchspot`_ If you are a proud user of Zinnia, send me the URL of your website and I will add it to the list. @@ -120,12 +120,12 @@ More information and help available at these URLs: .. _`Sass3`: http://sass-lang.com/ .. _`Windows Live Writer`: http://explore.live.com/windows-live-writer .. _`Fantomas' side`: http://fantomas.site/blog/ -.. _`Ubuntu's developers blog`: http://developer.ubuntu.com/en/blog/ .. _`Vidzor Studio LLC`: http://vidzor.com/blog/ .. _`Bookshadow`: http://bookshadow.com/weblog/ .. _`Future Proof Games`: http://futureproofgames.com/blog/ .. _`Programeria`: https://programeria.pl/ .. _`Tihomir Blajev Blog`: http://www.tihoblajev.com/weblog/ +.. _`Branchspot`: https://www.branchspot.com/blog/ .. _`Code repository`: https://github.com/Fantomas42/django-blog-zinnia .. _`Documentation`: http://docs.django-blog-zinnia.com/ .. _`Travis CI server`: http://travis-ci.org/Fantomas42/django-blog-zinnia From ade3d3b11eff66f4ba42881a15dbee647df324cb Mon Sep 17 00:00:00 2001 From: renpj Date: Thu, 8 Feb 2018 00:12:27 -0800 Subject: [PATCH 5/5] modified: zinnia/views/tags.py --- zinnia/views/tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zinnia/views/tags.py b/zinnia/views/tags.py index ff27763ae..ab2fb5c3d 100644 --- a/zinnia/views/tags.py +++ b/zinnia/views/tags.py @@ -80,4 +80,4 @@ def get_model_name(self): """ The model name is the tag slugified. """ - return slugify(self.tag) + return slugify(self.tag.name)