Changeset 352
- Timestamp:
- 07/18/10 21:05:52 (7 weeks ago)
- Location:
- Python/blog/trunk
- Files:
-
- 6 added
- 5 edited
-
AUTHORS (modified) (1 diff)
-
Changes (modified) (1 diff)
-
INSTALL (modified) (1 diff)
-
blog/rpc (added)
-
blog/rpc/__init__.py (added)
-
blog/rpc/decorators.py (added)
-
blog/rpc/metaweblog.py (added)
-
blog/rpc/utils.py (added)
-
blog/rpc/xmlrpc.py (added)
-
blog/templatetags/blog.py (modified) (4 diffs)
-
blog/urls.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Python/blog/trunk/AUTHORS
r348 r352 2 2 3 3 * Nicholas Studt <nicholas@nicholasstudt.com> 4 5 RPC Support 6 7 * Carson Gee http://carsonegee.com -
Python/blog/trunk/Changes
r350 r352 3 3 1.3 4 4 - Added {% csrf_token %} to search. 5 5 - RPC support for Blogger 1.0, MetaWeblog, and MoveableType (Patch 6 provided by Carson Gee.) 7 6 8 1.2 (May 3 2010): 7 9 - Added author list page, which shows all authors. -
Python/blog/trunk/INSTALL
r331 r352 84 84 85 85 </style> 86 87 * Configure RPC 88 89 By default, uploads to settings.MEDIA_ROOT/[datestamp]_[orig_name]. 90 91 If settings.BLOG_RPC_UPLOAD_PATH is set to a tuple, I will run 92 strftime against it, and append the passed in filename to the end of 93 the time format string. The tuple should be ( file_path, url_path ) 94 95 If you set settings.BLOG_RPC_UPLOAD_PATH as a python callable, I will 96 call it with **kwargs set at {user: django user object, author_id: 97 blog author id, name: file name to upload } which must return a tuple 98 that is a valid path and URL to that path. 99 100 Two settings.py examples: 101 102 1) 103 BLOG_RPC_UPLOAD_PATH = ("/home/cgee/tmp/blog/%Y/%m/%d/", "/static_media/%Y/%m/%d/") 104 105 2) 106 import time 107 def rpc_path(**kwargs): 108 base_path = time.strftime('%d/%m/%Y/', time.localtime()) 109 base_path = "%s%s/%s" % (base_path, 110 kwargs['user'].username, 111 kwargs['name']) 112 return ("/home/cgee/tmp/blog/%s" % base_path, 113 "/static_media/%s" % base_path) 114 115 BLOG_RPC_UPLOAD_PATH = rpc_path 116 -
Python/blog/trunk/blog/templatetags/blog.py
r346 r352 42 42 return '' 43 43 44 class Calendar(template.Node): 45 def __init__(self, var_name, kind='month', limit=None, author=None): 46 self.var_name = var_name 47 self.kind = kind 48 self.limit = limit 49 self.author = author 50 51 def render(self, context): 52 author = None 53 54 if self.author: 55 try: 56 author = Author.objects.get(ident=self.author) 57 except ObjectDoesNotExist: 58 pass 59 60 if author: 61 list = Entry.objects.published(author=author).dates('pub_date', self.kind, order='DESC') 62 else: 63 list = Entry.objects.published().dates('pub_date', self.kind, 64 order='DESC') 65 66 if self.limit: 67 context[self.var_name] = list[:self.limit] 68 else: 69 context[self.var_name] = list 70 return '' 71 44 72 class TagList(template.Node): 45 73 def __init__(self, var_name): … … 76 104 def entry_archive(parser, token): 77 105 """ 78 List all of the tags.106 Listing of of years, months, or days that have entries. 79 107 80 108 Example:: … … 112 140 entry_archive = register.tag(entry_archive) 113 141 114 def month_cal(year=datetime.date.today().year, month=datetime.date.today().month): 142 def month_calendar(parser, token): 143 """ 144 Create a calendar of a month with the days that have entries linked 145 to that day in the archive. 146 147 Example:: 148 149 {% month_calendar <year> <month> [author_ident] %} 150 151 {% load blog %} 152 153 {% month_calendar 2010 11 author_ident_here %} 154 155 """ 156 157 author = None 158 year = datetime.date.today().year 159 month = datetime.date.today().month 160 161 bits = token.contents.split() 162 163 if len(bits) < 2: 164 raise TemplateSyntaxError, "'%s' tag requires at least the context name to populate" % bits[0] 165 166 if len(bits) >= 3: 167 (limit, type) = bits[2].split(':') 168 try: 169 limit = int(limit) 170 except ValueError: 171 limit = None 172 173 if len(bits) == 4: 174 author = bits[3] 175 176 return Calendar(bits[1], type, limit, author) 177 entry_archive = register.tag(entry_archive) 178 179 def month_cal(parser, token): 180 year=datetime.date.today().year 181 month=datetime.date.today().month 115 182 116 183 # Fix this to just use calendar.* for all math. … … 121 188 122 189 last_day_of_calendar = datetime.date(year,month,last_day_of_month[1]) + datetime.timedelta(7 - calendar.weekday(year,month,last_day_of_month[1])) 190 191 return last_day_of_calendar 123 192 124 193 event_list = Entry.objects.published(pub_date__gte=first_day_of_calendar, pub_date__lte=last_day_of_calendar) -
Python/blog/trunk/blog/urls.py
r339 r352 53 53 url(r'^latest/?$', 'blog.views.entry_latest', name="entry_latest"), 54 54 55 # New RPC handling 56 url(r'^rpc/?$', 'blog.rpc.xmlrpc.view', {'module': 'blog.rpc.metaweblog' }), 57 55 58 url(r'^(?P<author>[-\w]+)/?$', 'blog.views.entry_list', 56 59 name="author_index"), … … 58 61 url(r'^$', 'blog.views.entry_list', name="entry_index"), 59 62 ) 60
Note: See TracChangeset
for help on using the changeset viewer.