├── README ├── aws.py ├── cookbook.py ├── images.py ├── schema.sql ├── settings-template.py ├── static ├── css │ └── base.css ├── favicon.ico └── js │ ├── base.js │ └── jquery.js └── templates ├── activity-item.html ├── activity-stream.html ├── base.html ├── category.html ├── cookbook.html ├── edit.html ├── facepile.html ├── home-empty.html ├── home.html ├── recipe-actions.html ├── recipe-clips.html ├── recipe-context.html ├── recipe-info.html ├── recipe-list.html ├── recipe-photo-upload.html ├── recipe-photo.html └── recipe.html /README: -------------------------------------------------------------------------------- 1 | A social cookbook based on Facebook's Open Graph: 2 | https://developers.facebook.com/docs/beta/opengraph/. 3 | 4 | You can see all the recipes in your friends' cookbooks in addition to your 5 | own. When you add a recipe to your cookbook or cook a recipe, your friends 6 | will see it in an activity feed on Social Cookbook as well as Facebook 7 | via Open Graph. 8 | 9 | You can play with the site at http://socialcookbook.me/ 10 | 11 | To run your own version of the site or locally, copy settings-template.py to 12 | settings.py and edit all the options to your local setup. The Amazon S3 and 13 | CloudFront settings are required to support photo uploads for your recipes. 14 | The rest of the options should be self-explanatory. 15 | -------------------------------------------------------------------------------- /aws.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2011 Bret Taylor 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | # not use this file except in compliance with the License. You may obtain 7 | # a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | # License for the specific language governing permissions and limitations 15 | # under the License. 16 | 17 | """A Tornado-based Amazon S3 client""" 18 | 19 | import base64 20 | import email.utils 21 | import hashlib 22 | import hmac 23 | import mimetypes 24 | import re 25 | import time 26 | import tornado.httpclient 27 | import urllib 28 | 29 | from tornado.options import define, options 30 | 31 | define("aws_access_key_id") 32 | define("aws_secret_access_key") 33 | 34 | 35 | class S3Client(object): 36 | def __init__(self, bucket, access_key_id=None, secret_access_key=None): 37 | self.bucket = bucket 38 | if access_key_id is not None: 39 | self.access_key_id = access_key_id 40 | self.secret_access_key = secret_access_key 41 | else: 42 | self.access_key_id = options.aws_access_key_id 43 | self.secret_access_key = options.aws_secret_access_key 44 | if isinstance(self.secret_access_key, unicode): 45 | self.secret_access_key = self.secret_access_key.encode("utf-8") 46 | self.host = "http://" + bucket + ".s3.amazonaws.com" 47 | 48 | def put_object(self, key, body, callback, headers={}): 49 | headers = self._default_headers(headers) 50 | headers["Content-Length"] = len(body) 51 | if self.access_key_id: 52 | headers["Authorization"] = self._auth_header("PUT", key, headers) 53 | http = tornado.httpclient.AsyncHTTPClient() 54 | http.fetch(self.host + "/" + key, method="PUT", headers=headers, 55 | body=body, callback=callback) 56 | 57 | def put_cdn_content(self, data, callback, file_name=None, mime_type=None): 58 | """Uploads the given data as an object optimized for CloudFront. 59 | 60 | The object name is the hash of the mime type and file contents, 61 | so every unique file is represented exactly once in the CDN. We 62 | set the HTTP headers on the object to be optimized for public CDN 63 | consumption, including an infinite expiration time (since the file 64 | is named by its contents, it is guaranteed not to change) and the 65 | appropriate public Amazon ACL. 66 | 67 | If file_name is given, we include that in the object as a 68 | Content-Disposition header, so if a user saves the file, it will 69 | have a friendlier name upon download. If given, we also infer 70 | the mime type from the file name. 71 | 72 | We return the hash we used as the object name. 73 | """ 74 | # Infer the mime type and extension if not given 75 | if not mime_type and file_name: 76 | mime_type, encoding = mimetypes.guess_type(file_name) 77 | if not mime_type: 78 | mime_type = "application/unknown" 79 | if isinstance(mime_type, unicode): 80 | mime_type = mime_type.encode("utf-8") 81 | 82 | # Cache the file forever, and inlcude the mime type in the file hash 83 | # since the Content-Type header will change the way the browser renders 84 | headers = { 85 | "Content-Type": mime_type, 86 | "Expires": email.utils.formatdate(time.time() + 86400 * 365 * 10), 87 | "Cache-Control": "public, max-age=" + str(86400 * 365 * 10), 88 | "Vary": "Accept-Encoding", 89 | "x-amz-acl": "public-read", 90 | } 91 | file_hash = hashlib.sha1(mime_type + "|" + data).hexdigest() 92 | 93 | # Retain the file name for friendly downloading 94 | if file_name: 95 | if file_name != re.sub(r"[\x00-\x1f]", " ", file_name)[:4000]: 96 | raise Exception("Unsafe file name %r" % file_name) 97 | file_name = file_name.split("/")[-1] 98 | file_name = file_name.split("\\")[-1] 99 | file_name = file_name.replace('"', '').strip() 100 | if isinstance(file_name, unicode): 101 | file_name = file_name.encode("utf-8") 102 | if file_name: 103 | headers["Content-Disposition"] = \ 104 | 'inline; filename="%s"' % file_name 105 | 106 | def on_put(response): 107 | if response.error: 108 | logging.error("Amazon S3 error: %r", response) 109 | callback(None) 110 | else: 111 | callback(file_hash) 112 | self.put_object(file_hash, data, callback=on_put, headers=headers) 113 | 114 | def _default_headers(self, custom={}): 115 | headers = { 116 | "Date": email.utils.formatdate(time.time()) 117 | } 118 | headers.update(custom) 119 | return headers 120 | 121 | def _auth_header(self, method, key, headers): 122 | special_headers = ("content-md5", "content-type", "date") 123 | signed_headers = dict((k, "") for k in special_headers) 124 | signed_headers.update( 125 | (k.lower(), v) for k, v in headers.items() 126 | if k.lower().startswith("x-amz-") or k.lower() in special_headers) 127 | sorted_header_keys = list(sorted(signed_headers.keys())) 128 | 129 | buffer = "%s\n" % method 130 | for header_key in sorted_header_keys: 131 | if header_key.startswith("x-amz-"): 132 | buffer += "%s:%s\n" % (header_key, signed_headers[header_key]) 133 | else: 134 | buffer += "%s\n" % signed_headers[header_key] 135 | buffer += "/%s" % self.bucket + "/%s" % urllib.quote_plus(key) 136 | 137 | signature = hmac.new(self.secret_access_key, buffer, hashlib.sha1) 138 | return "AWS " + self.access_key_id + ":" + \ 139 | base64.encodestring(signature.digest()).strip() 140 | -------------------------------------------------------------------------------- /cookbook.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2011 Bret Taylor 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | # not use this file except in compliance with the License. You may obtain 7 | # a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | # License for the specific language governing permissions and limitations 15 | # under the License. 16 | 17 | import aws 18 | import base64 19 | import datetime 20 | import functools 21 | import images 22 | import json 23 | import logging 24 | import os.path 25 | import random 26 | import re 27 | import string 28 | import tornado.database 29 | import tornado.escape 30 | import tornado.httpclient 31 | import tornado.ioloop 32 | import tornado.web 33 | import urllib 34 | import urlparse 35 | 36 | from tornado.options import define, options 37 | 38 | define("aws_s3_bucket") 39 | define("aws_cloudfront_host") 40 | define("compiled_css_url") 41 | define("compiled_jquery_url") 42 | define("compiled_js_url") 43 | define("config") 44 | define("cookie_secret") 45 | define("comments", type=bool, default=True) 46 | define("debug", type=bool) 47 | define("facebook_app_id") 48 | define("facebook_app_secret") 49 | define("facebook_canvas_id") 50 | define("mysql_host") 51 | define("mysql_database") 52 | define("mysql_user") 53 | define("mysql_password") 54 | define("port", type=int, default=8080) 55 | define("silent", type=bool) 56 | 57 | 58 | class CookbookApplication(tornado.web.Application): 59 | def __init__(self): 60 | base_dir = os.path.dirname(__file__) 61 | settings = { 62 | "cookie_secret": options.cookie_secret, 63 | "static_path": os.path.join(base_dir, "static"), 64 | "template_path": os.path.join(base_dir, "templates"), 65 | "debug": options.debug, 66 | "ui_modules": { 67 | "RecipeList": RecipeList, 68 | "RecipeClips": RecipeClips, 69 | "ActivityStream": ActivityStream, 70 | "ActivityItem": ActivityItem, 71 | "RecipePhoto": RecipePhoto, 72 | "RecipeInfo": RecipeInfo, 73 | "RecipeActions": RecipeActions, 74 | "RecipeContext": RecipeContext, 75 | "Facepile": Facepile, 76 | }, 77 | } 78 | tornado.web.Application.__init__(self, [ 79 | tornado.web.url(r"/", HomeHandler, name="home"), 80 | tornado.web.url(r"/recipe/([^/]+)", RecipeHandler, name="recipe"), 81 | tornado.web.url(r"/category", CategoryHandler, name="category"), 82 | tornado.web.url(r"/cookbook/([^/]+)", CookbookHandler, 83 | name="cookbook"), 84 | tornado.web.url(r"/edit", EditHandler, name="edit"), 85 | tornado.web.url(r"/a/login", LoginHandler, name="login"), 86 | tornado.web.url(r"/a/clip", ClipHandler, name="clip"), 87 | tornado.web.url(r"/a/cook", CookHandler, name="cook"), 88 | tornado.web.url(r"/a/upload", UploadHandler, name="upload"), 89 | ], **settings) 90 | 91 | 92 | class BaseHandler(tornado.web.RequestHandler): 93 | @property 94 | def backend(self): 95 | return Backend.instance() 96 | 97 | def get_current_user(self): 98 | uid = self.get_secure_cookie("uid") 99 | return self.backend.get_user(uid) if uid else None 100 | 101 | def get_login_url(self, next=None): 102 | if not next: 103 | next = self.request.full_url() 104 | if not next.startswith("http://") and not next.startswith("https://"): 105 | next = urlparse.urljoin(self.request.full_url(), next) 106 | if self.get_argument("code", None): 107 | return "http://" + self.request.host + \ 108 | self.reverse_url("login") + "?" + urllib.urlencode({ 109 | "next": next, 110 | "code": self.get_argument("code"), 111 | }) 112 | redirect_uri = "http://" + self.request.host + \ 113 | self.reverse_url("login") + "?" + urllib.urlencode({"next": next}) 114 | if self.get_argument("code", None): 115 | args["code"] = self.get_argument("code") 116 | return "https://www.facebook.com/dialog/oauth?" + urllib.urlencode({ 117 | "client_id": options.facebook_app_id, 118 | "redirect_uri": redirect_uri, 119 | "scope": "offline_access,publish_actions", 120 | }) 121 | 122 | def write_json(self, obj): 123 | self.set_header("Content-Type", "application/json; charset=UTF-8") 124 | self.finish(json.dumps(obj)) 125 | 126 | def render(self, template, **kwargs): 127 | kwargs["error_message"] = self.get_secure_cookie("message") 128 | if kwargs["error_message"]: 129 | kwargs["error_message"] = base64.b64decode(kwargs["error_message"]) 130 | self.clear_cookie("message") 131 | tornado.web.RequestHandler.render(self, template, **kwargs) 132 | 133 | def render_string(self, template, **kwargs): 134 | args = { 135 | "markdown": self.markdown, 136 | "options": options, 137 | "user_possessive": self.user_possessive, 138 | "user_link": self.user_link, 139 | "friend_list": self.friend_list, 140 | } 141 | args.update(kwargs) 142 | return tornado.web.RequestHandler.render_string(self, template, **args) 143 | 144 | def set_error_message(self, message): 145 | self.set_secure_cookie("message", base64.b64encode(message)) 146 | 147 | def user_possessive(self, user): 148 | if user["gender"] == "male": 149 | return "his" 150 | else: 151 | return "her" 152 | 153 | def friend_list(self, friends, size=3): 154 | if len(friends) == 1: 155 | return self.user_link(friends[0], True, True) 156 | elif len(friends) > size + 1: 157 | return ", ".join(self.user_link(f, True, i == 0) for i, f in 158 | enumerate(friends[:size])) + \ 159 | " and " + str(len(friends) - size) + " other friends" 160 | else: 161 | return ", ".join(self.user_link(f, True, i == 0) for i, f in 162 | enumerate(friends[:len(friends) - 1])) + \ 163 | " and " + \ 164 | self.user_link(friends[len(friends) - 1], True, False) 165 | 166 | def user_link(self, user, you=False, capitalize=True): 167 | if you and self.current_user and self.current_user["id"] == user["id"]: 168 | name = "You" if capitalize else "you" 169 | else: 170 | name = user["name"] 171 | return '' + \ 172 | tornado.escape.xhtml_escape(name) + '' 173 | 174 | def markdown(self, text): 175 | text = re.sub(r"\n\s*\n", "

", 176 | tornado.escape.xhtml_escape(text.strip())) 177 | text = re.sub(r"\n", "
", text) 178 | return '

' + text + '

' 179 | 180 | 181 | class HomeHandler(BaseHandler): 182 | @tornado.web.authenticated 183 | def get(self): 184 | all_recipes = self.backend.get_recently_clipped_recipes( 185 | [self.current_user["id"]]) 186 | existing_ids = set(r["id"] for r in all_recipes) 187 | friends_recent = self.backend.get_recently_clipped_recipes( 188 | self.backend.get_friend_ids(self.current_user), 10, existing_ids) 189 | user_recipe_ids = set(r["id"] for r in all_recipes) 190 | friends_recent = [r for r in friends_recent 191 | if r["id"] not in user_recipe_ids] 192 | user_recent = all_recipes[:2] if friends_recent else all_recipes[:4] 193 | if not all_recipes: 194 | friends_recent = friends_recent[:6] 195 | elif len(all_recipes) < 4: 196 | friends_recent = friends_recent[:4] 197 | else: 198 | friends_recent = friends_recent[:2] 199 | if not all_recipes and len(friends_recent) < 2: 200 | self.render("home-empty.html") 201 | return 202 | self.render("home.html", all_recipes=all_recipes, 203 | user_recent=user_recent, friends_recent=friends_recent) 204 | 205 | 206 | class UploadHandler(BaseHandler): 207 | @tornado.web.authenticated 208 | @tornado.web.asynchronous 209 | def post(self): 210 | recipe = self.backend.get_recipe(int(self.get_argument("recipe"))) 211 | if not recipe: 212 | raise tornado.web.HTTPError(404) 213 | if recipe["photo"] and recipe["author_id"] != self.current_user["id"]: 214 | raise tornado.web.HTTPError(403) 215 | full = images.resize_image( 216 | self.request.files.values()[0][0]["body"], max_width=800, 217 | max_height=800, quality=85) 218 | thumb = images.resize_image( 219 | self.request.files.values()[0][0]["body"], max_width=300, 220 | max_height=800, quality=85) 221 | resized = {"full": full, "thumb": thumb} 222 | if full["width"] < 300 or full["height"] < 300: 223 | self.set_error_message( 224 | "Recipe images must be at least 300 pixels wide and " 225 | "300 pixels tall.") 226 | self.redirect(self.reverse_url("recipe", recipe["slug"])) 227 | return 228 | thumb["uploaded"] = False 229 | full["uploaded"] = False 230 | self.backend.s3.put_cdn_content( 231 | data=thumb["data"], mime_type=thumb["mime_type"], 232 | callback=functools.partial( 233 | self.on_upload, "thumb", recipe, resized)) 234 | self.backend.s3.put_cdn_content( 235 | data=full["data"], mime_type=full["mime_type"], 236 | callback=functools.partial( 237 | self.on_upload, "full", recipe, resized)) 238 | 239 | def on_upload(self, image_size, recipe, images, hash): 240 | if not hash: 241 | raise tornado.web.HTTPError(500) 242 | images[image_size]["uploaded"] = True 243 | images[image_size]["hash"] = hash 244 | if images["thumb"]["uploaded"] and images["full"]["uploaded"]: 245 | self.backend.save_photos(recipe, images["full"], images["thumb"]) 246 | self.redirect(self.reverse_url("recipe", recipe["slug"])) 247 | url = "http://" + self.request.host + \ 248 | self.reverse_url("recipe", recipe["slug"]) 249 | # Force Facebook to recrawl the object to get the new image 250 | ping_url = "http://developers.facebook.com/tools/lint/?" + \ 251 | urllib.urlencode({"url": url}) 252 | client = tornado.httpclient.AsyncHTTPClient() 253 | client.fetch(ping_url, self.on_ping) 254 | 255 | def on_ping(self, response): 256 | if response.error: 257 | logging.error("Error refreshing Open Graph page: %r", 258 | response.error) 259 | 260 | 261 | class RecipeHandler(BaseHandler): 262 | @tornado.web.asynchronous 263 | def get(self, slug): 264 | if "facebookexternalhit" not in self.request.headers["User-Agent"] \ 265 | and not self.current_user: 266 | self.redirect(self.get_login_url()) 267 | return 268 | recipe = self.backend.get_recipe_by_slug(slug) 269 | if not recipe: 270 | raise tornado.web.HTTPError(404) 271 | self.render("recipe.html", recipe=recipe) 272 | 273 | 274 | class CookbookHandler(BaseHandler): 275 | def get(self, id): 276 | user = self.backend.get_user(id) 277 | if not user: 278 | raise tornado.web.HTTPError(404) 279 | recipes = self.backend.get_recently_clipped_recipes([user["id"]]) 280 | self.render("cookbook.html", user=user, recipes=recipes) 281 | 282 | 283 | class CategoryHandler(BaseHandler): 284 | @tornado.web.authenticated 285 | def get(self): 286 | category = self.get_argument("name") 287 | recipes = self.backend.get_recently_clipped_recipes( 288 | [self.current_user.id], category=category) 289 | recipes.sort(key=lambda r: r["title"].lower()) 290 | friend_recipes = self.backend.get_recently_clipped_recipes( 291 | self.backend.get_friend_ids(self.current_user), category=category, 292 | exclude_ids=[r["id"] for r in recipes])[:4] 293 | self.render("category.html", category=category, recipes=recipes, 294 | friend_recipes=friend_recipes) 295 | 296 | 297 | class EditHandler(BaseHandler): 298 | @tornado.web.authenticated 299 | def get(self): 300 | id = self.get_argument("id", None) 301 | recipe = self.backend.get_recipe(int(id)) if id else None 302 | if recipe and recipe["author_id"] != self.current_user["id"]: 303 | raise tornado.web.HTTPError(403) 304 | categories = self.backend.get_categories(self.current_user) 305 | self.render("edit.html", recipe=recipe, categories=categories) 306 | 307 | @tornado.web.authenticated 308 | def post(self): 309 | id = self.get_argument("id", None) 310 | recipe = self.backend.get_recipe(int(id)) if id else None 311 | if recipe: 312 | created = False 313 | if recipe["author_id"] != self.current_user["id"]: 314 | raise tornado.web.HTTPError(403) 315 | self.backend.update_recipe( 316 | id=recipe["id"], 317 | title=self.get_argument("title"), 318 | category=self.get_argument("category"), 319 | description=self.get_argument("description"), 320 | instructions=self.get_argument("instructions", ""), 321 | ingredients=self.get_argument("ingredients", ""), 322 | ) 323 | else: 324 | created = True 325 | id = self.backend.create_recipe( 326 | author=self.current_user, 327 | title=self.get_argument("title"), 328 | category=self.get_argument("category"), 329 | description=self.get_argument("description"), 330 | instructions=self.get_argument("instructions", ""), 331 | ingredients=self.get_argument("ingredients", ""), 332 | ) 333 | self.backend.clip_recipe(user=self.current_user, recipe_id=id) 334 | recipe = self.backend.get_recipe(int(id)) 335 | self.redirect(self.reverse_url("recipe", recipe["slug"])) 336 | if not options.silent and created: 337 | url = "http://" + self.request.host + \ 338 | self.reverse_url("recipe", recipe["slug"]) 339 | self.backend.save_open_graph_action( 340 | type="clip", recipe=url, user=self.current_user, 341 | callback=self.on_open_graph) 342 | 343 | def on_open_graph(self, response): 344 | if response.error: 345 | logging.error("Error publishing clip to open graph: %r", 346 | response.error) 347 | 348 | 349 | class ClipHandler(BaseHandler): 350 | @tornado.web.authenticated 351 | def post(self): 352 | recipe_id = int(self.get_argument("recipe")) 353 | recipe = self.backend.get_recipe(recipe_id) 354 | if not recipe: 355 | raise tornado.web.HTTPError(404) 356 | if not options.silent: 357 | self.backend.clip_recipe(self.current_user, recipe["id"]) 358 | self.write_json({ 359 | "html": self.ui.modules.ActivityItem( 360 | self.current_user, recipe, datetime.datetime.utcnow(), 361 | "clipped"), 362 | }) 363 | url = "http://" + self.request.host + \ 364 | self.reverse_url("recipe", recipe["slug"]) 365 | if not options.silent: 366 | self.backend.save_open_graph_action( 367 | type="clip", recipe=url, user=self.current_user, 368 | callback=self.on_open_graph) 369 | 370 | def on_open_graph(self, response): 371 | if response.error: 372 | logging.error("Error publishing clip to open graph: %r", 373 | response.error) 374 | 375 | 376 | class CookHandler(BaseHandler): 377 | @tornado.web.authenticated 378 | def post(self): 379 | recipe_id = int(self.get_argument("recipe")) 380 | recipe = self.backend.get_recipe(recipe_id) 381 | if not recipe: 382 | raise tornado.web.HTTPError(404) 383 | if not options.silent: 384 | self.backend.cook_recipe(self.current_user, recipe["id"]) 385 | self.write_json({ 386 | "html": self.ui.modules.ActivityItem( 387 | self.current_user, recipe, datetime.datetime.utcnow(), 388 | "cooked"), 389 | }) 390 | url = "http://" + self.request.host + \ 391 | self.reverse_url("recipe", recipe["slug"]) 392 | if not options.silent: 393 | self.backend.save_open_graph_action( 394 | type="cook", recipe=url, user=self.current_user, 395 | callback=self.on_open_graph) 396 | 397 | def on_open_graph(self, response): 398 | if response.error: 399 | logging.error("Error publishing cook to open graph: %r (%r)", 400 | response.error, response.body) 401 | 402 | 403 | class LoginHandler(BaseHandler): 404 | @tornado.web.asynchronous 405 | def get(self): 406 | next = self.get_argument("next", None) 407 | code = self.get_argument("code", None) 408 | if not next: 409 | self.redirect(self.get_login_url(self.reverse_url("home"))) 410 | return 411 | if not next.startswith("https://" + self.request.host + "/") and \ 412 | not next.startswith("http://" + self.request.host + "/"): 413 | raise tornado.web.HTTPError( 414 | 404, "Login redirect (%s) spans hosts", next) 415 | if self.get_argument("error", None): 416 | logging.warning("Facebook login error: %r", self.request.arguments) 417 | self.set_error_message( 418 | "An error occured with Facebook. Please try again later.") 419 | self.redirect(self.reverse_url("home")) 420 | return 421 | if not code: 422 | self.redirect(self.get_login_url(next)) 423 | return 424 | redirect_uri = self.request.protocol + "://" + self.request.host + \ 425 | self.request.path + "?" + urllib.urlencode({"next": next}) 426 | url = "https://graph.facebook.com/oauth/access_token?" + \ 427 | urllib.urlencode({ 428 | "client_id": options.facebook_app_id, 429 | "client_secret": options.facebook_app_secret, 430 | "redirect_uri": redirect_uri, 431 | "code": code, 432 | }) 433 | client = tornado.httpclient.AsyncHTTPClient() 434 | client.fetch(url, self.on_access_token) 435 | 436 | def on_access_token(self, response): 437 | if response.error: 438 | self.set_error_message( 439 | "An error occured with Facebook. Please try again later.") 440 | self.redirect(self.reverse_url("home")) 441 | return 442 | access_token = urlparse.parse_qs(response.body)["access_token"][-1] 443 | url = "https://graph.facebook.com/me?" + urllib.urlencode({ 444 | "access_token": access_token, 445 | }) 446 | client = tornado.httpclient.AsyncHTTPClient() 447 | client.fetch(url, functools.partial(self.on_profile, access_token)) 448 | 449 | def on_profile(self, access_token, response): 450 | if response.error: 451 | self.set_error_message( 452 | "An error occured with Facebook. Please try again later.") 453 | self.redirect(self.reverse_url("home")) 454 | return 455 | profile = json.loads(response.body) 456 | url = "https://graph.facebook.com/me/friends?" + urllib.urlencode({ 457 | "access_token": access_token, 458 | }) 459 | client = tornado.httpclient.AsyncHTTPClient() 460 | client.fetch(url, functools.partial( 461 | self.on_friends, access_token, profile)) 462 | 463 | def on_friends(self, access_token, profile, response): 464 | if response.error: 465 | self.set_error_message( 466 | "An error occured with Facebook. Please try again later.") 467 | self.redirect(self.reverse_url("home")) 468 | return 469 | friend_ids = [f["id"] for f in json.loads(response.body)["data"]] 470 | self.backend.create_user(profile, access_token) 471 | self.backend.update_friends(profile, friend_ids) 472 | self.set_secure_cookie("uid", profile["id"]) 473 | self.redirect(self.get_argument("next", self.reverse_url("home"))) 474 | 475 | 476 | class Backend(object): 477 | def __init__(self): 478 | self.db = tornado.database.Connection( 479 | host=options.mysql_host, database=options.mysql_database, 480 | user=options.mysql_user, password=options.mysql_password) 481 | self.s3 = aws.S3Client(options.aws_s3_bucket) 482 | 483 | @classmethod 484 | def instance(cls): 485 | if not hasattr(cls, "_instance"): 486 | cls._instance = cls() 487 | return cls._instance 488 | 489 | def save_open_graph_action(self, user, type, callback, **properties): 490 | url = "https://graph.facebook.com/me/" + options.facebook_canvas_id + \ 491 | ":" + type 492 | properties.update({ 493 | "access_token": user["access_token"], 494 | }) 495 | client = tornado.httpclient.AsyncHTTPClient() 496 | client.fetch(url, method="POST", body=urllib.urlencode(properties), 497 | callback=callback) 498 | 499 | def get_user(self, id): 500 | return self.get_users([id]).get(id) 501 | 502 | def get_users(self, ids): 503 | if not ids: 504 | return {} 505 | users = self.db.query( 506 | "SELECT * FROM cookbook_users WHERE id IN (" + 507 | ",".join(["%s"] * len(ids)) + ")", *ids) 508 | for user in users: 509 | user["picture"] = "http://graph.facebook.com/" + user["id"] + \ 510 | "/picture" 511 | return dict((a["id"], a) for a in users) 512 | 513 | def create_user(self, profile, access_token): 514 | profile.setdefault("gender", "male") 515 | self.db.execute( 516 | "INSERT IGNORE INTO cookbook_users (id,name,link,gender," 517 | "access_token,created) VALUES (%s,%s,%s,%s,%s,UTC_TIMESTAMP) " 518 | "ON DUPLICATE KEY UPDATE name=%s, link=%s, gender=%s, " 519 | "access_token = %s", 520 | profile["id"], profile["name"], profile["link"], profile["gender"], 521 | access_token, profile["name"], profile["link"], profile["gender"], 522 | access_token) 523 | 524 | def update_friends(self, user, friend_ids): 525 | if not friend_ids: 526 | return 527 | friend_ids = [r["id"] for r in self.db.query( 528 | "SELECT * FROM cookbook_users WHERE id IN (" + 529 | ",".join(["%s"] * len(friend_ids)) + ")", *friend_ids)] 530 | if not friend_ids: 531 | return 532 | rows = [(user["id"], fid) for fid in friend_ids] 533 | rows += [(fid, user["id"]) for fid in friend_ids] 534 | self.db.executemany( 535 | "INSERT IGNORE INTO cookbook_friends (user_id, friend_id) " 536 | "VALUES (%s,%s)", rows) 537 | 538 | def get_friend_ids(self, user): 539 | return [r["friend_id"] for r in self.db.query( 540 | "SELECT friend_id FROM cookbook_friends WHERE user_id = %s", 541 | user["id"])] 542 | 543 | def get_recipe(self, id): 544 | return self.get_recipes([id]).get(id) 545 | 546 | def get_recipe_by_slug(self, slug): 547 | recipe = self.db.get( 548 | "SELECT * FROM cookbook_recipes WHERE slug = %s", slug) 549 | if not recipe: 550 | return None 551 | self._fill_recipes([recipe]) 552 | return recipe 553 | 554 | def create_recipe(self, title, category, description, ingredients, 555 | instructions, author): 556 | slug_base = title.replace(" ", "-").lower() 557 | valid_letters = string.ascii_letters + string.digits + "-" 558 | slug_base = "".join(c for c in slug_base if c in valid_letters)[:90] 559 | tries = 0 560 | while True: 561 | try: 562 | slug = slug_base + "-" + str(tries) if tries > 0 else slug_base 563 | return self.db.execute( 564 | "INSERT INTO cookbook_recipes (title,category,description," 565 | "ingredients,instructions,author_id,slug,created) VALUES " 566 | "(%s,%s,%s,%s,%s,%s,%s,UTC_TIMESTAMP)", title, category, 567 | description, ingredients, instructions, author["id"], slug) 568 | except tornado.database.IntegrityError: 569 | tries += 1 570 | 571 | def update_recipe(self, id, title, category, description, ingredients, 572 | instructions): 573 | return self.db.execute( 574 | "UPDATE cookbook_recipes SET title = %s, category = %s, " 575 | "description = %s, ingredients = %s, instructions = %s " 576 | "WHERE id = %s", title, category, description, ingredients, 577 | instructions, id) 578 | 579 | def clip_recipe(self, user, recipe_id): 580 | self.db.execute( 581 | "INSERT IGNORE INTO cookbook_clipped (user_id, recipe_id) " 582 | "VALUES (%s,%s)", user["id"], recipe_id) 583 | 584 | def cook_recipe(self, user, recipe_id): 585 | self.db.execute( 586 | "INSERT IGNORE INTO cookbook_cooked (user_id, recipe_id) " 587 | "VALUES (%s,%s)", user["id"], recipe_id) 588 | 589 | def get_clipped_recipes(self, user): 590 | recipe_ids = [row["recipe_id"] for row in self.db.query( 591 | "SELECT recipe_id FROM cookbook_clipped WHERE user_id = %s", 592 | user["id"])] 593 | return self.get_recipes(recipe_ids).values() 594 | 595 | def save_photos(self, recipe, full, thumb): 596 | self.db.execute( 597 | "REPLACE INTO cookbook_photos (recipe_id,full_hash,full_width," 598 | "full_height,thumb_hash,thumb_width,thumb_height) VALUES " 599 | "(%s,%s,%s,%s,%s,%s,%s)", recipe["id"], full["hash"], 600 | full["width"], full["height"], thumb["hash"], thumb["width"], 601 | thumb["height"]) 602 | 603 | def get_recently_clipped_recipes(self, user_ids, num=None, 604 | exclude_ids=None, category=None): 605 | if not user_ids: 606 | return [] 607 | query = "SELECT DISTINCT recipe_id FROM cookbook_clipped WHERE " \ 608 | "user_id IN (" + ",".join(["%s"] * len(user_ids)) + ")" 609 | args = list(user_ids) 610 | if exclude_ids: 611 | query += " AND recipe_id NOT IN (" + \ 612 | ",".join(["%s"] * len(exclude_ids)) + ")" 613 | args += exclude_ids 614 | query += " ORDER BY created DESC" 615 | if num is not None: 616 | query += " LIMIT " + str(num) 617 | recipe_ids = [row["recipe_id"] for row in self.db.query(query, *args)] 618 | recipe_map = self.get_recipes(recipe_ids) 619 | if category: 620 | return [recipe_map[id] for id in recipe_ids 621 | if recipe_map[id]["category"] == category] 622 | else: 623 | return [recipe_map[id] for id in recipe_ids] 624 | 625 | def get_recently_cooked_recipes(self, user, num): 626 | recipe_ids = [row["recipe_id"] for row in self.db.query( 627 | "SELECT recipe_id FROM cookbook_cooked WHERE user_id = %s " 628 | "ORDER BY created DESC LIMIT " + str(num), user["id"])] 629 | recipe_map = self.get_recipes(recipe_ids) 630 | return [recipe_map[id] for id in recipe_ids] 631 | 632 | def get_friend_activity(self, user, num): 633 | friend_ids = self.get_friend_ids(user) + [user["id"]] 634 | activity = self._make_activity("cooked", self.db.query( 635 | "SELECT user_id, recipe_id, created FROM cookbook_cooked WHERE " 636 | "user_id IN (" + ",".join(["%s"] * len(friend_ids)) + ") ORDER BY " 637 | "created DESC LIMIT " + str(num), *friend_ids)) 638 | activity += self._make_activity("clipped", self.db.query( 639 | "SELECT user_id, recipe_id, created FROM cookbook_clipped WHERE " 640 | "user_id IN (" + ",".join(["%s"] * len(friend_ids)) + ") ORDER BY " 641 | "created DESC LIMIT " + str(num), *friend_ids)) 642 | activity.sort(key=lambda a: a["created"], reverse=True) 643 | activity = activity[:num] 644 | users = self.get_users(set(a["user_id"] for a in activity)) 645 | recipes = self.get_recipes(set(a["recipe_id"] for a in activity)) 646 | for item in activity: 647 | item["user"] = users[item["user_id"]] 648 | item["recipe"] = recipes[item["recipe_id"]] 649 | return activity 650 | 651 | def get_recipes(self, ids): 652 | if not ids: 653 | return {} 654 | recipes = dict((r["id"], r) for r in self.db.query( 655 | "SELECT * FROM cookbook_recipes WHERE id IN (" + 656 | ",".join(["%s"] * len(ids)) + ")", *ids)) 657 | self._fill_recipes(recipes.values()) 658 | return recipes 659 | 660 | def get_categories(self, user): 661 | friend_ids = self.get_friend_ids(user) + [user["id"]] 662 | recipe_ids = [r["recipe_id"] for r in self.db.query( 663 | "SELECT DISTINCT recipe_id FROM cookbook_clipped WHERE " 664 | "user_id IN (" + ",".join(["%s"] * len(friend_ids)) + ")", 665 | *friend_ids)] 666 | if not recipe_ids: 667 | return [] 668 | categories = [r["category"] for r in self.db.query( 669 | "SELECT DISTINCT category FROM cookbook_recipes WHERE id " 670 | "IN (" + ",".join(["%s"] * len(recipe_ids)) + ")", *recipe_ids)] 671 | categories.sort(key=lambda c: c.lower()) 672 | return categories 673 | 674 | def recipe_is_clipped(self, user, recipe): 675 | return self.db.get( 676 | "SELECT recipe_id FROM cookbook_clipped WHERE user_id = %s AND " 677 | "recipe_id = %s", user["id"], recipe["id"]) is not None 678 | 679 | def get_friends_who_clipped(self, user, recipe): 680 | all_friends = self.get_friend_ids(user) 681 | if not all_friends: 682 | return [] 683 | friend_ids = [r["user_id"] for r in self.db.query( 684 | "SELECT user_id FROM cookbook_clipped WHERE recipe_id = %s AND " 685 | "user_id IN (" + ",".join(["%s"] * len(all_friends)) + ") " 686 | "ORDER BY created DESC", recipe["id"], *all_friends)] 687 | friends = self.get_users(friend_ids) 688 | return [friends[fid] for fid in friend_ids] 689 | 690 | def get_clip_count(self, recipe): 691 | return self.db.get( 692 | "SELECT COUNT(*) AS num FROM cookbook_clipped WHERE " 693 | "recipe_id = %s", recipe["id"]).num 694 | 695 | def get_cook_count(self, recipe): 696 | return self.db.get( 697 | "SELECT COUNT(*) AS num FROM cookbook_cooked WHERE " 698 | "recipe_id = %s", recipe["id"]).num 699 | 700 | def get_recipe_photos(self, recipe_ids): 701 | if not recipe_ids: 702 | return {} 703 | photos = {} 704 | for row in self.db.query( 705 | "SELECT * FROM cookbook_photos WHERE recipe_id IN (" + 706 | ",".join(["%s"] * len(recipe_ids)) + ")", *recipe_ids): 707 | photos[row["recipe_id"]] = { 708 | "full": { 709 | "hash": row["full_hash"], 710 | "url": cdn_url(row["full_hash"]), 711 | "width": row["full_width"], 712 | "height": row["full_height"], 713 | }, 714 | "thumb": { 715 | "hash": row["thumb_hash"], 716 | "url": cdn_url(row["thumb_hash"]), 717 | "width": row["thumb_width"], 718 | "height": row["thumb_height"], 719 | }, 720 | } 721 | return photos 722 | 723 | def _fill_recipes(self, recipes): 724 | author_ids = set(r["author_id"] for r in recipes) 725 | recipe_ids = set(r["id"] for r in recipes) 726 | authors = self.get_users(author_ids) 727 | photos = self.get_recipe_photos(recipe_ids) 728 | for recipe in recipes: 729 | recipe["author"] = authors[recipe["author_id"]] 730 | recipe["photo"] = photos.get(recipe["id"]) 731 | 732 | def _make_activity(self, action, rows): 733 | for row in rows: 734 | row["action"] = action 735 | return rows 736 | 737 | 738 | class RecipeList(tornado.web.UIModule): 739 | def render(self, recipes): 740 | categories = {} 741 | for recipe in recipes: 742 | categories.setdefault(recipe["category"], []).append(recipe) 743 | for recipes in categories.itervalues(): 744 | recipes.sort(key=lambda r: r["title"].lower()) 745 | return self.render_string("recipe-list.html", categories=categories) 746 | 747 | 748 | class Facepile(tornado.web.UIModule): 749 | def render(self, friends, num=7): 750 | return self.render_string("facepile.html", friends=friends, num=num) 751 | 752 | 753 | class RecipeClips(tornado.web.UIModule): 754 | def render(self, recipes): 755 | return self.render_string("recipe-clips.html", recipes=recipes) 756 | 757 | 758 | class ActivityStream(tornado.web.UIModule): 759 | def render(self, num=10): 760 | if not self.current_user: 761 | return "" 762 | activity = self.handler.backend.get_friend_activity( 763 | self.current_user, num=num) 764 | if not activity: 765 | return "" 766 | return self.render_string("activity-stream.html", activity=activity) 767 | 768 | 769 | class ActivityItem(tornado.web.UIModule): 770 | def render(self, user, recipe, date, action): 771 | return self.render_string( 772 | "activity-item.html", user=user, recipe=recipe, date=date, 773 | action=action) 774 | 775 | 776 | class RecipePhoto(tornado.web.UIModule): 777 | def render(self, recipe, width, max_height=None, height=None, href=None): 778 | if not recipe["photo"]: 779 | if not height: 780 | height = max_height 781 | return self.render_string( 782 | "recipe-photo-upload.html", recipe=recipe, width=width, 783 | height=height) 784 | thumb = recipe["photo"]["thumb"] 785 | if max_height: 786 | ratio = width / (1.0 * thumb["width"]) 787 | visible_height = min(int(ratio * thumb["height"]), max_height) 788 | else: 789 | ratio = max(height / (1.0 * thumb["height"]), 790 | width / (1.0 * thumb["width"])) 791 | visible_height = height 792 | real_width = int(ratio * thumb["width"]) 793 | real_height = int(ratio * thumb["height"]) 794 | offset_x = (width - real_width) / 2 795 | offset_y = (visible_height - real_height) / 2 796 | return self.render_string( 797 | "recipe-photo.html", recipe=recipe, href=href, 798 | real_width=real_width, real_height=real_height, offset_x=offset_x, 799 | offset_y=offset_y, width=width, height=visible_height) 800 | 801 | 802 | class RecipeActions(tornado.web.UIModule): 803 | def render(self, recipe): 804 | clipped = self.handler.backend.recipe_is_clipped( 805 | self.current_user, recipe) 806 | return self.render_string( 807 | "recipe-actions.html", recipe=recipe, clipped=clipped) 808 | 809 | 810 | class RecipeInfo(tornado.web.UIModule): 811 | def render(self, recipe): 812 | cook_count = self.handler.backend.get_cook_count(recipe) 813 | clip_count = self.handler.backend.get_clip_count(recipe) 814 | return self.render_string( 815 | "recipe-info.html", recipe=recipe, cook_count=cook_count, 816 | clip_count=clip_count) 817 | 818 | 819 | class RecipeContext(tornado.web.UIModule): 820 | def render(self, recipe, facepile_size=5, friend_list_size=3): 821 | friends = self.handler.backend.get_friends_who_clipped( 822 | self.current_user, recipe) 823 | if not friends: 824 | return "" 825 | clipped = self.handler.backend.recipe_is_clipped( 826 | self.current_user, recipe) 827 | return self.render_string( 828 | "recipe-context.html", recipe=recipe, friends=friends, 829 | clipped=clipped, friend_list_size=friend_list_size, 830 | facepile_size=facepile_size) 831 | 832 | 833 | def cdn_url(hash): 834 | return "http://" + options.aws_cloudfront_host + "/" + hash 835 | 836 | 837 | def main(): 838 | tornado.options.parse_command_line() 839 | if options.config: 840 | tornado.options.parse_config_file(options.config) 841 | else: 842 | path = os.path.join(os.path.dirname(__file__), "settings.py") 843 | tornado.options.parse_config_file(path) 844 | CookbookApplication().listen(options.port) 845 | tornado.ioloop.IOLoop.instance().start() 846 | 847 | 848 | if __name__ == "__main__": 849 | main() 850 | -------------------------------------------------------------------------------- /images.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2011 Bret Taylor 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 6 | # not use this file except in compliance with the License. You may obtain 7 | # a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | # License for the specific language governing permissions and limitations 15 | # under the License. 16 | 17 | """An image resizing library based on ImageMagick and ctypes""" 18 | 19 | import binascii 20 | import ctypes 21 | import ctypes.util 22 | 23 | 24 | def get_image_info(data): 25 | """Returns the width, height, and MIME type of the given image as a dict""" 26 | return _ImageMagick.instance().get_image_info(data) 27 | 28 | 29 | def resize_image(data, max_width, max_height, quality=85, crop=False, 30 | force=False): 31 | """Resizes the given image to the given specifications. 32 | 33 | We size down the image to the given maximum width and height. Unless force 34 | is True, we don't resize an image smaller than the given width and height. 35 | 36 | We use the JPEG format for any image that has to be resized. If the image 37 | does not have to be resized, we retain the original image format. 38 | 39 | If crop is True, we resize the image so that at least one of the width or 40 | height is within the given bounds, and then we crop the other dimension. 41 | 42 | We use the given JPEG quality in the cases where we use the JPEG format. 43 | We always convert to JPEG for image formats other than PNG and GIF. 44 | 45 | We return a dict with the keys "data", "mime_type", "width", and "height". 46 | """ 47 | return _ImageMagick.instance().resize_image( 48 | data=data, max_width=max_width, max_height=max_height, quality=quality, 49 | crop=crop, force=force) 50 | 51 | 52 | class ImageException(Exception): 53 | """An exception related to the ImageMagick library""" 54 | pass 55 | 56 | 57 | class _ImageMagick(object): 58 | def __init__(self): 59 | wand_path = ctypes.util.find_library("MagickWand") 60 | if not wand_path: 61 | raise Exception("Package libmagick9 or libmagick10 required") 62 | self.lib = ctypes.CDLL(wand_path) 63 | method = self.lib.MagickResizeImage 64 | method.restype = ctypes.c_int 65 | method.argtypes = (ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, 66 | ctypes.c_int, ctypes.c_double) 67 | self.pixel_wand = self.lib.NewPixelWand() 68 | self.lib.PixelSetColor(self.pixel_wand, "#ffffff") 69 | 70 | @classmethod 71 | def instance(cls): 72 | if not hasattr(cls, "_instance"): 73 | cls._instance = cls() 74 | return cls._instance 75 | 76 | def get_image_info(self, data): 77 | wand = self.lib.NewMagickWand() 78 | try: 79 | if not self.lib.MagickReadImageBlob(wand, data, len(data)): 80 | raise ImageException("Unsupported image format; data: %s...", 81 | binascii.b2a_hex(data[:32])) 82 | ptr = self.lib.MagickGetImageFormat(wand) 83 | format = ctypes.string_at(ptr).upper() 84 | self.lib.MagickRelinquishMemory(ptr) 85 | return { 86 | "mime_type": "image/" + format.lower(), 87 | "width": self.lib.MagickGetImageWidth(wand), 88 | "height": self.lib.MagickGetImageHeight(wand), 89 | } 90 | finally: 91 | self.lib.DestroyMagickWand(wand) 92 | 93 | def resize_image(self, data, max_width, max_height, quality=85, 94 | crop=False, force=False): 95 | wand = self.lib.NewMagickWand() 96 | try: 97 | if not self.lib.MagickReadImageBlob(wand, data, len(data)): 98 | raise ImageException("Unsupported image format; data: %s...", 99 | binascii.b2a_hex(data[:32])) 100 | width = self.lib.MagickGetImageWidth(wand) 101 | height = self.lib.MagickGetImageHeight(wand) 102 | self.lib.MagickStripImage(wand) 103 | if crop: 104 | ratio = max(max_height * 1.0 / height, max_width * 1.0 / width) 105 | else: 106 | ratio = min(max_height * 1.0 / height, max_width * 1.0 / width) 107 | 108 | ptr = self.lib.MagickGetImageFormat(wand) 109 | src_format = ctypes.string_at(ptr).upper() 110 | self.lib.MagickRelinquishMemory(ptr) 111 | format = src_format 112 | 113 | if ratio < 1.0 or force: 114 | format = "JPEG" 115 | self.lib.MagickResizeImage( 116 | wand, int(ratio * width + 0.5), int(ratio * height + 0.5), 117 | 0, 1.0) 118 | elif format not in ("GIF", "JPEG", "PNG"): 119 | format = "JPEG" 120 | 121 | if format != src_format: 122 | # Flatten to fix background on transparent images. We have to 123 | # do this before cropping, as MagickFlattenImages appears to 124 | # drop all the crop info from that step 125 | self.lib.MagickSetImageBackgroundColor(wand, self.pixel_wand) 126 | flat_wand = self.lib.MagickFlattenImages(wand) 127 | self.lib.DestroyMagickWand(wand) 128 | wand = flat_wand 129 | 130 | if crop: 131 | x = (self.lib.MagickGetImageWidth(wand) - max_width) / 2 132 | y = (self.lib.MagickGetImageHeight(wand) - max_height) / 2 133 | self.lib.MagickCropImage(wand, max_width, max_height, x, y) 134 | 135 | if format == "JPEG": 136 | # Default compression is best for PNG, GIF. 137 | self.lib.MagickSetCompressionQuality(wand, quality) 138 | 139 | self.lib.MagickSetFormat(wand, format) 140 | size = ctypes.c_size_t() 141 | ptr = self.lib.MagickGetImageBlob(wand, ctypes.byref(size)) 142 | body = ctypes.string_at(ptr, size.value) 143 | self.lib.MagickRelinquishMemory(ptr) 144 | 145 | return { 146 | "data": body, 147 | "mime_type": "image/" + format.lower(), 148 | "width": self.lib.MagickGetImageWidth(wand), 149 | "height": self.lib.MagickGetImageHeight(wand), 150 | } 151 | finally: 152 | self.lib.DestroyMagickWand(wand) 153 | -------------------------------------------------------------------------------- /schema.sql: -------------------------------------------------------------------------------- 1 | -- Copyright 2011 Bret Taylor 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | -- not use this file except in compliance with the License. You may obtain 5 | -- a copy of the License at 6 | -- 7 | -- http://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | -- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | -- License for the specific language governing permissions and limitations 13 | -- under the License. 14 | 15 | SET SESSION storage_engine = "InnoDB"; 16 | SET SESSION time_zone = "+0:00"; 17 | ALTER DATABASE CHARACTER SET "utf8"; 18 | 19 | DROP TABLE IF EXISTS cookbook_recipes; 20 | CREATE TABLE cookbook_recipes ( 21 | id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 22 | author_id VARCHAR(25) NOT NULL REFERENCES cookbook_users(id), 23 | slug VARCHAR(100) NOT NULL UNIQUE, 24 | title VARCHAR(512) NOT NULL, 25 | category VARCHAR(512) NOT NULL, 26 | description MEDIUMTEXT NOT NULL, 27 | ingredients MEDIUMTEXT NOT NULL, 28 | instructions MEDIUMTEXT NOT NULL, 29 | created DATETIME NOT NULL, 30 | updated TIMESTAMP NOT NULL, 31 | KEY (author_id, created), 32 | KEY (category) 33 | ); 34 | 35 | DROP TABLE IF EXISTS cookbook_users; 36 | CREATE TABLE cookbook_users ( 37 | id VARCHAR(25) NOT NULL PRIMARY KEY, 38 | link VARCHAR(255) NOT NULL, 39 | name VARCHAR(100) NOT NULL, 40 | gender VARCHAR(25) NOT NULL, 41 | access_token VARCHAR(255) NOT NULL, 42 | created DATETIME NOT NULL, 43 | updated TIMESTAMP NOT NULL 44 | ); 45 | 46 | DROP TABLE IF EXISTS cookbook_friends; 47 | CREATE TABLE cookbook_friends ( 48 | user_id VARCHAR(25) NOT NULL, 49 | friend_id VARCHAR(25) NOT NULL, 50 | created TIMESTAMP NOT NULL, 51 | PRIMARY KEY (user_id, friend_id) 52 | ); 53 | 54 | DROP TABLE IF EXISTS cookbook_clipped; 55 | CREATE TABLE cookbook_clipped ( 56 | user_id VARCHAR(25) NOT NULL REFERENCES cookbook_users(id), 57 | recipe_id INT NOT NULL REFERENCES cookbook_recipes(id), 58 | created TIMESTAMP NOT NULL, 59 | PRIMARY KEY (user_id, recipe_id), 60 | KEY (user_id, created), 61 | KEY (recipe_id) 62 | ); 63 | 64 | DROP TABLE IF EXISTS cookbook_cooked; 65 | CREATE TABLE cookbook_cooked ( 66 | user_id VARCHAR(25) NOT NULL REFERENCES cookbook_users(id), 67 | recipe_id INT NOT NULL REFERENCES cookbook_recipes(id), 68 | created TIMESTAMP NOT NULL, 69 | KEY (user_id, recipe_id), 70 | KEY (user_id, created), 71 | KEY (recipe_id) 72 | ); 73 | 74 | DROP TABLE IF EXISTS cookbook_photos; 75 | CREATE TABLE cookbook_photos ( 76 | recipe_id INT NOT NULL PRIMARY KEY REFERENCES cookbook_recipes(id), 77 | created TIMESTAMP NOT NULL, 78 | full_hash VARCHAR(40) NOT NULL, 79 | full_width INT NOT NULL, 80 | full_height INT NOT NULL, 81 | thumb_hash VARCHAR(40) NOT NULL, 82 | thumb_width INT NOT NULL, 83 | thumb_height INT NOT NULL 84 | ); 85 | -------------------------------------------------------------------------------- /settings-template.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | port = 8000 4 | cookie_secret = "" 5 | 6 | facebook_app_id = "" 7 | facebook_app_secret = "" 8 | facebook_canvas_id = "" 9 | 10 | mysql_database = "" 11 | mysql_user = "" 12 | mysql_password = "" 13 | mysql_host = "" 14 | 15 | aws_access_key_id = "" 16 | aws_secret_access_key = "" 17 | aws_s3_bucket = "" 18 | aws_cloudfront_host = "" 19 | 20 | compiled_css_url = "" 21 | compiled_js_url = "" 22 | compiled_jquery_url = "" 23 | -------------------------------------------------------------------------------- /static/css/base.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2011 Facebook */ 2 | 3 | body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, 4 | pre, a, code, em, img, dl, dt, dd, ol, ul, li, form, table, caption, th, 5 | td, canvas, embed, button { 6 | margin: 0; 7 | padding: 0; 8 | border: 0; 9 | } 10 | 11 | ul, ol { 12 | list-style-type: none; 13 | } 14 | 15 | body { 16 | background: white; 17 | margin: 0; 18 | margin-bottom: 25px; 19 | } 20 | 21 | body, 22 | input, 23 | textarea, 24 | td, 25 | button { 26 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 27 | font-size: 13px; 28 | text-rendering: optimizeLegibility; 29 | -webkit-font-smoothing: antialiased; 30 | color: #333; 31 | } 32 | 33 | a { 34 | color: #3b5998; 35 | text-decoration: none; 36 | } 37 | 38 | a.name { 39 | font-weight: bold; 40 | } 41 | 42 | a:hover { 43 | text-decoration: underline; 44 | } 45 | 46 | .column { 47 | margin: auto; 48 | width: 1000px; 49 | } 50 | 51 | 52 | /* Buttons */ 53 | 54 | button, 55 | a.button, 56 | button.primary:disabled, 57 | button:disabled:hover, 58 | button.primary:disabled:hover, 59 | button:disabled:active, 60 | button.primary:disabled:active { 61 | cursor: pointer; 62 | margin: 0; 63 | outline-style: none; 64 | 65 | border: 1px solid #bcbcbc; 66 | border-bottom-color: #a2a2a2; 67 | border-top-color: #c9c9c9; 68 | border-radius: 5px; 69 | -webkit-border-radius: 5px; 70 | -moz-border-radius: 5px; 71 | 72 | box-shadow: rgba(0, 0, 0, 0.1) 0 1px 0 0; 73 | -webkit-box-shadow: rgba(0, 0, 0, 0.1) 0 1px 0 0; 74 | -moz-box-shadow: rgba(0, 0, 0, 0.1) 0 1px 0 0; 75 | 76 | padding: 5px; 77 | padding-left: 11px; 78 | padding-right: 11px; 79 | 80 | background: #f9f9f9; 81 | background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#f6f6f6)); 82 | background: -moz-linear-gradient(top, #ffffff, #f6f6f6); 83 | 84 | text-decoration: none; 85 | font-weight: bold; 86 | color: #333; 87 | } 88 | 89 | a.button:hover, 90 | button:hover { 91 | border-color: #a2a2a2; 92 | text-decoration: none; 93 | } 94 | 95 | a.button:active, 96 | button:active { 97 | background: #f6f6f6; 98 | } 99 | 100 | button.primary { 101 | border-color: #3a5691; 102 | border-bottom-color: #1b305d; 103 | 104 | background: #4f6aa3; 105 | background: -webkit-gradient(linear, left top, left bottom, from(#738cc0), to(#4f6aa3)); 106 | background: -moz-linear-gradient(top, #738cc0, #4f6aa3); 107 | 108 | text-shadow: none; 109 | color: white; 110 | } 111 | 112 | button.primary:hover { 113 | border-color: #1b305d; 114 | } 115 | 116 | button.primary:active { 117 | background: #4f6aa3; 118 | } 119 | 120 | button:disabled, 121 | button:disabled:hover, 122 | button:disabled:active { 123 | color: #aaa; 124 | } 125 | 126 | 127 | /* Layout */ 128 | 129 | #page { 130 | margin-top: 20px; 131 | overflow: hidden; 132 | } 133 | 134 | #error div { 135 | border: 1px solid #be3333; 136 | background: #feb8b8; 137 | padding: 8px;; 138 | margin-bottom: 16px; 139 | font-weight: bold; 140 | } 141 | 142 | #body { 143 | margin-right: 285px; 144 | } 145 | 146 | #sidebar { 147 | float: right; 148 | width: 235px; 149 | margin-top: 30px; 150 | padding-left: 18px; 151 | border-left: 1px solid #ddd; 152 | 153 | } 154 | 155 | 156 | /* Sidebar */ 157 | 158 | #sidebar .actions button, 159 | #sidebar .actions a.button, 160 | .homeempty a.button { 161 | font-size: 16px; 162 | padding: 8px; 163 | padding-left: 20px; 164 | padding-right: 20px; 165 | -webkit-transition: opacity 0.25s ease-in-out; 166 | } 167 | 168 | #sidebar .actions .help { 169 | margin-top: 5px; 170 | color: #999; 171 | } 172 | 173 | #sidebar .info { 174 | margin-top: 25px; 175 | } 176 | 177 | #sidebar .info .facepile { 178 | margin-bottom: 5px; 179 | } 180 | 181 | #sidebar .info .stats { 182 | margin-top: 1em; 183 | } 184 | 185 | #sidebar .info .stats b { 186 | font-size: 175%; 187 | padding-right: 2px; 188 | } 189 | 190 | .activity { 191 | margin-top: 25px; 192 | } 193 | 194 | .activity h3 { 195 | font-size: 13px; 196 | margin-bottom: 10px; 197 | } 198 | 199 | .activity .action { 200 | padding-top: 6px; 201 | padding-bottom: 6px; 202 | overflow: hidden; 203 | -webkit-transition: background-color 0.25s ease-in-out; 204 | } 205 | 206 | .activity .action.highlighted { 207 | background-color: #fffcdb; 208 | } 209 | 210 | .activity .action .picture { 211 | display: block; 212 | line-height: 0; 213 | float: left; 214 | } 215 | 216 | .activity .action .picture img { 217 | width: 40px; 218 | height: 40px; 219 | } 220 | 221 | .activity .action .body { 222 | margin-left: 47px; 223 | } 224 | 225 | .activity .action .time { 226 | display: block; 227 | color: #999; 228 | font-size: 11px; 229 | margin-top: 2px; 230 | } 231 | 232 | 233 | /* Recipe */ 234 | 235 | .recipe h1, 236 | .category h1, 237 | .cookbook h1, 238 | .homeempty h1, 239 | .edit input[name=title] { 240 | font-size: 30px; 241 | font-weight: bold; 242 | } 243 | 244 | .breadcrumbs { 245 | color: #999; 246 | margin-bottom: 6px; 247 | } 248 | 249 | .recipe .description, 250 | .recipe .ingredients, 251 | .recipe .instructions, 252 | .homeempty p, 253 | .edit textarea { 254 | font-family: Georgia, serif; 255 | font-size: 16px; 256 | line-height: 23px; 257 | } 258 | 259 | p { 260 | margin-bottom: 1em; 261 | } 262 | 263 | .recipe h1 { 264 | margin-bottom: 13px; 265 | } 266 | 267 | .recipe .description { 268 | background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAjBAMAAADyPp7ZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj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Y7v399ByI8fVHBeNT9OyThhl3E18zLh0+drPWAYAnCRrmQGR51r64aIptj+x/W1eylqI8gAAAABJRU5ErkJggg==') no-repeat top left; 269 | padding-top: 20px; 270 | padding-left: 52px; 271 | } 272 | 273 | .recipe .meta { 274 | margin-left: 325px; 275 | } 276 | 277 | .recipe .author { 278 | color: #999; 279 | overflow: hidden; 280 | margin-left: 52px; 281 | } 282 | 283 | .recipe .author .picture { 284 | display: block; 285 | line-height: 0; 286 | float: left; 287 | } 288 | 289 | .recipe .author .picture img { 290 | width: 50px; 291 | height: 50px; 292 | } 293 | 294 | .recipe .author .body { 295 | margin-left: 58px; 296 | margin-top: 16px; 297 | } 298 | 299 | .recipe .photos { 300 | float: left; 301 | width: 306px; 302 | } 303 | 304 | .recipe .text { 305 | clear: left; 306 | } 307 | 308 | .recipe .edit { 309 | margin-top: 3px; 310 | } 311 | 312 | .recipe h2, 313 | .edit h2, 314 | .category h2 { 315 | color: #999; 316 | font-weight: normal; 317 | font-size: 22px; 318 | margin-top: 23px; 319 | margin-bottom: 6px; 320 | } 321 | 322 | .photo { 323 | display: block; 324 | border: 1px solid #ccc; 325 | padding: 2px; 326 | } 327 | 328 | .photo span { 329 | display: block; 330 | overflow: hidden; 331 | } 332 | 333 | .facepile { 334 | overflow: hidden; 335 | white-space: nowrap; 336 | } 337 | 338 | .facepile a { 339 | display: block; 340 | width: 40px; 341 | height: 40px; 342 | background-size: 40px 40px; 343 | margin-right: 3px; 344 | float: left; 345 | } 346 | 347 | .context .names { 348 | margin-top: 3px; 349 | } 350 | 351 | 352 | /* Home */ 353 | 354 | .home h2 { 355 | font-size: 30px; 356 | margin-bottom: 10px; 357 | } 358 | 359 | .section { 360 | margin-bottom: 30px; 361 | } 362 | 363 | .clips { 364 | overflow: hidden; 365 | margin-bottom: 25px; 366 | } 367 | 368 | div.clip { 369 | width: 348px; 370 | padding-right: 15px; 371 | float: left; 372 | height: 156px; 373 | position: relative; 374 | } 375 | 376 | .clip:last-child { 377 | padding-right: 0; 378 | width: 352px; 379 | } 380 | 381 | .clip h3 { 382 | font-size: 20px; 383 | margin-left: 164px; 384 | } 385 | 386 | .clip .context { 387 | position: absolute; 388 | padding-right: 12px; 389 | left: 164px; 390 | bottom: 0; 391 | } 392 | 393 | .clip:last-child .context { 394 | padding-right: 0; 395 | } 396 | 397 | .clip .photo { 398 | float: left; 399 | } 400 | 401 | .photoupload span { 402 | background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABBBAMAAAB/btpeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RTREMDI1QzU5N0IwMTFFMEIxQzI5QTYwRUY4Qzc4NEIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RTREMDI1QzY5N0IwMTFFMEIxQzI5QTYwRUY4Qzc4NEIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpFNEQwMjVDMzk3QjAxMUUwQjFDMjlBNjBFRjhDNzg0QiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpFNEQwMjVDNDk3QjAxMUUwQjFDMjlBNjBFRjhDNzg0QiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkoZaIEAAAASUExURf///ztZmG2EtI2fxdTb6dTc6RqdAfkAAAABdFJOUwBA5thmAAAAXklEQVQ4y2MwUsIODBjAQIEBO1CgjrQLFuBAP2lnHJ5Xhkg74XA+E3WkWUOxgBElLSg6OKUDBcGANtKDzN/gFIk7xiiRhpQtOKUZ8OumhzSuHEoFaWacZcsoGAV0AgDoePgUifLGWgAAAABJRU5ErkJggg==') no-repeat center center; 403 | background-color: #eceff6; 404 | position: relative; 405 | } 406 | 407 | .photoupload span span { 408 | background: none; 409 | position: absolute; 410 | top: 50%; 411 | left: 0; 412 | width: 100%; 413 | padding-top: 19px; 414 | text-align: center; 415 | font-size: 11px; 416 | } 417 | 418 | a.photo.photoupload:hover { 419 | text-decoration: none; 420 | } 421 | 422 | #uploaddialog p { 423 | margin-bottom: 1em; 424 | } 425 | 426 | #uploaddialog { 427 | display: none; 428 | } 429 | 430 | .dialog .loading { 431 | display: none; 432 | float: left; 433 | font-size: 11px; 434 | padding-left: 24px; 435 | margin-top: 8px; 436 | margin-left: 3px; 437 | background: url('data:image/gif;base64,R0lGODlhEAALAMQaAPT09PDw8JeXl6Ojo+/v76ioqL6+vr29vbS0tOLi4uPj49fX1+jo6KysrODg4JiYmMvLy6Wlpc7Ozvn5+bW1tevr6/X19ZaWlvf39+7u7v///wAAAAAAAAAAAAAA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m4r1ah0WoYAACH5BAULABoALAAAAAABAAEAAAUDoBYCADs=') no-repeat left center; 438 | color: gray; 439 | } 440 | 441 | 442 | /* Dialog */ 443 | 444 | .dialog { 445 | background-color: rgba(82, 82, 82, 0.65); 446 | border-radius: 8px; 447 | -webkit-border-radius: 8px; 448 | -moz-border-radius: 8px; 449 | padding: 8px; 450 | position: fixed; 451 | top: 125px; 452 | left: 50%; 453 | margin-left: -250px; 454 | width: 500px; 455 | z-index: 100; 456 | } 457 | 458 | .dialog h2, 459 | .dialog .body, 460 | .dialog .buttons { 461 | padding: 7px; 462 | padding-left: 10px; 463 | padding-right: 10px; 464 | } 465 | 466 | .dialog h2 { 467 | background: #5988b4; 468 | border: 1px solid #3b5998; 469 | border-bottom-style: none; 470 | display: block; 471 | color: white; 472 | font-size: 15px; 473 | } 474 | 475 | .dialog .body { 476 | border: 1px solid #555; 477 | border-top-style: none; 478 | border-bottom-color: #ccc; 479 | background: white; 480 | } 481 | 482 | .dialog .buttons { 483 | background: #f2f2f2; 484 | border: 1px solid #555; 485 | border-top-style: none; 486 | text-align: right; 487 | } 488 | 489 | .dialog .buttons button { 490 | margin-left: 5px; 491 | } 492 | 493 | 494 | /* Edit form */ 495 | 496 | .edit textarea, 497 | .edit input { 498 | width: 600px; 499 | } 500 | 501 | .edit textarea { 502 | height: 200px; 503 | } 504 | 505 | .edit textarea[name=description] { 506 | height: 50px; 507 | } 508 | 509 | .edit input[name=category] { 510 | width: 200px; 511 | } 512 | 513 | .edit h2, 514 | .edit .buttons { 515 | margin-top: 13px; 516 | } 517 | 518 | 519 | .edit .note { 520 | color: #999; 521 | float: right; 522 | margin-top: 20px; 523 | margin-right: 110px; 524 | } 525 | 526 | 527 | /* Recipe index */ 528 | 529 | .category h1, 530 | .cookbook h1, 531 | .homeempty h1 { 532 | margin-bottom: 6px; 533 | } 534 | 535 | .index { 536 | overflow: hidden; 537 | } 538 | 539 | .index .lhs { 540 | float: left; 541 | width: 343px; 542 | } 543 | 544 | .index .rhs { 545 | margin-left: 363px; 546 | } 547 | 548 | .index li { 549 | font-family: Georgia, serif; 550 | font-size: 16px; 551 | line-height: 23px; 552 | } 553 | 554 | .index h3 { 555 | color: #999; 556 | font-weight: normal; 557 | font-size: 22px; 558 | margin-top: 10px; 559 | margin-bottom: 3px; 560 | } 561 | 562 | 563 | /* Header */ 564 | 565 | #header { 566 | background: #5988b4; 567 | background: -webkit-gradient(linear, left top, left bottom, from(#6e99bf), to(#5988b4)); 568 | background: -moz-linear-gradient(top, #6e99bf, #5988b4); 569 | height: 39px; 570 | box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); 571 | -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); 572 | -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); 573 | } 574 | 575 | #header, 576 | #header a { 577 | color: white; 578 | text-shadow: rgba(36, 81, 124, 0.5) 0 -1px 0; 579 | } 580 | 581 | #header ul { 582 | list-style-type: none; 583 | float: right; 584 | } 585 | 586 | #header ul li { 587 | float: left; 588 | } 589 | 590 | #header ul a { 591 | display: block; 592 | line-height: 39px; 593 | padding-left: 12px; 594 | padding-right: 12px; 595 | font-weight: bold; 596 | } 597 | 598 | #logo { 599 | display: block; 600 | width: 235px; 601 | height: 39px; 602 | background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOsAAAAhCAYAAAA4eVwHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYg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hZ3vilqn7vpiC3VUKVryKdXn2B5vzZNlNeJf1c7yZMwxApVS6MdbvBltiycD9+YxxAGwBYknjE9NyfiLLYKLvZCYwY8YOgRAZjo+PWr/Ib4klA/+3br4KeQQ/8fK8XioWljPR1fQCM7398iXrz2dYYskD+sNUTB6HvAJJZMwYZW4Qy0uvE9HbBpQUQK/aLSTH2vorcpZYEjqwWmKJJRZYLbHEEj3yX/9y7UChP61tAAAAAElFTkSuQmCC') no-repeat center center; 603 | } 604 | -------------------------------------------------------------------------------- /static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/finiteloop/socialcookbook/9c18fc528491582ca6019a7f6bf6bf414e1c97e8/static/favicon.ico -------------------------------------------------------------------------------- /static/js/base.js: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Facebook 2 | 3 | $(function() { 4 | $("button.newrecipe").live("click", function() { 5 | location.href = "/edit"; 6 | return false; 7 | }); 8 | $("a.photoupload").live("click", function() { 9 | $("#uploaddialog input[name=recipe]").val($(this).attr("recipe")); 10 | $("#uploaddialog").fadeIn(150); 11 | return false; 12 | }); 13 | // TODO: Loading indicators 14 | $("button.clip").live("click", function() { 15 | var button = $(this); 16 | button.attr("disabled", "disabled"); 17 | $.post("/a/clip", {recipe: $(this).attr("recipe")}, 18 | function(response) { 19 | $(".activity h3").after(response.html); 20 | highlight($(".activity .action:first")); 21 | button.get(0).className = "cook"; 22 | button.css({"opacity": 0}); 23 | window.setTimeout(function() { 24 | button.removeAttr("disabled"); 25 | button.text("I just cooked this"); 26 | button.css({"opacity": 1}); 27 | }, 300); 28 | }); 29 | return false; 30 | }); 31 | $("button.cook").live("click", function() { 32 | var button = $(this); 33 | button.attr("disabled", "disabled"); 34 | $.post("/a/cook", {recipe: $(this).attr("recipe")}, 35 | function(response) { 36 | button.removeAttr("disabled"); 37 | $(".activity h3").after(response.html); 38 | highlight($(".activity .action:first")); 39 | }); 40 | return false; 41 | }); 42 | $("button.dialogcancel").live("click", function() { 43 | $(this).parents("form").find("button").removeAttr("disabled"); 44 | $(this).parents(".dialog").fadeOut(150).find(".loading").hide(); 45 | }); 46 | $("#uploaddialog form").live("submit", function() { 47 | $("#uploaddialog button[type=submit]").attr("disabled", "disabled"); 48 | $("#uploaddialog .loading").show(); 49 | return true; 50 | }); 51 | $("#uploaddialog input[type=file]").live("change", function() { 52 | $(this).parents("form").submit(); 53 | }); 54 | $("a.newcategory").live("click", function() { 55 | var div = $(this).parent(); 56 | var current = div.find("select").val(); 57 | div.html('').find("input").val(current).select(); 58 | return false; 59 | }); 60 | $("form.edit").live("submit", function() { 61 | var required = ["title", "description", "category"]; 62 | for (var i = 0; i < required.length; i++) { 63 | if (!this[required[i]].value) { 64 | this[required[i]].select(); 65 | return false; 66 | } 67 | } 68 | return true; 69 | }); 70 | window.setTimeout(function() { 71 | $("#error").slideUp(); 72 | }, 4000); 73 | }); 74 | 75 | 76 | function highlight(node) { 77 | node.addClass("highlighted"); 78 | node.hide(); 79 | node.slideDown(); 80 | window.setTimeout(function() { 81 | node.removeClass("highlighted"); 82 | }, 1500); 83 | } 84 | -------------------------------------------------------------------------------- /static/js/jquery.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v1.6.1 3 | * http://jquery.com/ 4 | * 5 | * Copyright 2011, John Resig 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | * http://jquery.org/license 8 | * 9 | * Includes Sizzle.js 10 | * http://sizzlejs.com/ 11 | * Copyright 2011, The Dojo Foundation 12 | * Released under the MIT, BSD, and GPL Licenses. 13 | * 14 | * Date: Thu May 12 15:04:36 2011 -0400 15 | */ 16 | (function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),c.body.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write("");b=cl.createElement(a),cl.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ck)}cj[a]=d}return cj[a]}function cu(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function ct(){cq=b}function cs(){setTimeout(ct,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g=0===c})}function W(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function O(a,b){return(a&&a!=="*"?a+".":"")+b.replace(A,"`").replace(B,"&")}function N(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function L(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function F(){return!0}function E(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"$1-$2").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.1",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};f=c.createElement("select"),g=f.appendChild(c.createElement("option")),h=a.getElementsByTagName("input")[0],j={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},h.checked=!0,j.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,j.optDisabled=!g.disabled;try{delete a.test}catch(s){j.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function b(){j.noCloneEvent=!1,a.detachEvent("onclick",b)}),a.cloneNode(!0).fireEvent("onclick")),h=c.createElement("input"),h.value="t",h.setAttribute("type","radio"),j.radioValue=h.value==="t",h.setAttribute("checked","checked"),a.appendChild(h),k=c.createDocumentFragment(),k.appendChild(a.firstChild),j.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",l=c.createElement("body"),m={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(q in m)l.style[q]=m[q];l.appendChild(a),b.insertBefore(l,b.firstChild),j.appendChecked=h.checked,j.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,j.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",j.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",n=a.getElementsByTagName("td"),r=n[0].offsetHeight===0,n[0].style.display="",n[1].style.display="none",j.reliableHiddenOffsets=r&&n[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(i=c.createElement("div"),i.style.width="0",i.style.marginRight="0",a.appendChild(i),j.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(i,null)||{marginRight:0}).marginRight,10)||0)===0),l.innerHTML="",b.removeChild(l);if(a.attachEvent)for(q in{submit:1,change:1,focusin:1})p="on"+q,r=p in a,r||(a.setAttribute(p,"return;"),r=typeof a[p]=="function"),j[q+"Bubbles"]=r;return j}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[f.camelCase(c)]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[f.camelCase(c)]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c],i||(!t.test(c)||typeof d!="boolean"&&d!==b&&d.toLowerCase()!==c.toLowerCase()?v&&(f.nodeName(a,"form")||u.test(c))&&(i=v):i=w);if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),w={get:function(a,c){return a[f.propFix[c]||c]?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=b),a.setAttribute(c,c.toLowerCase()));return c}},f.attrHooks.value={get:function(a,b){if(v&&f.nodeName(a,"button"))return v.get(a,b);return a.value},set:function(a,b,c){if(v&&f.nodeName(a,"button"))return v.set(a,b,c);a.value=b}},f.support.getSetAttribute||(f.attrFix=f.propFix,v=f.attrHooks.name=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var x=Object.prototype.hasOwnProperty,y=/\.(.*)$/,z=/^(?:textarea|input|select)$/i,A=/\./g,B=/ /g,C=/[^\w\s.|`]/g,D=function(a){return a.replace(C,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=E;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=E);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),D).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem 17 | )});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},K=function(c){var d=c.target,e,g;if(!!z.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=J(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:K,beforedeactivate:K,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&K.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&K.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",J(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in I)f.event.add(this,c+".specialChange",I[c]);return z.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return z.test(this.nodeName)}},I=f.event.special.change.filters,I.focus=I.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=U.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(W(c[0])||W(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=T.call(arguments);P.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!V[a]?f.unique(e):e,(this.length>1||R.test(d))&&Q.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var Y=/ jQuery\d+="(?:\d+|null)"/g,Z=/^\s+/,$=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,_=/<([\w:]+)/,ba=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Y,""):null;if(typeof a=="string"&&!bc.test(a)&&(f.support.leadingWhitespace||!Z.test(a))&&!bg[(_.exec(a)||["",""])[1].toLowerCase()]){a=a.replace($,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bj(a,d),e=bk(a),g=bk(d);for(h=0;e[h];++h)bj(e[h],g[h])}if(b){bi(a,d);if(c){e=bk(a),g=bk(d);for(h=0;e[h];++h)bi(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument|| 18 | b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!bb.test(k))k=b.createTextNode(k);else{k=k.replace($,"<$1>");var l=(_.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=ba.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&Z.test(k)&&o.insertBefore(b.createTextNode(Z.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bp.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bo.test(g)?g.replace(bo,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,c){var d,e,g;c=c.replace(br,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bs.test(d)&&bt.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bE=/%20/g,bF=/\[\]$/,bG=/\r?\n/g,bH=/#.*$/,bI=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bJ=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bK=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bL=/^(?:GET|HEAD)$/,bM=/^\/\//,bN=/\?/,bO=/)<[^<]*)*<\/script>/gi,bP=/^(?:select|textarea)/i,bQ=/\s+/,bR=/([?&])_=[^&]*/,bS=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bT=f.fn.load,bU={},bV={},bW,bX;try{bW=e.href}catch(bY){bW=c.createElement("a"),bW.href="",bW=bW.href}bX=bS.exec(bW.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bT)return bT.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bO,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bP.test(this.nodeName)||bJ.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bG,"\r\n")}}):{name:b.name,value:c.replace(bG,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bW,isLocal:bK.test(bX[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bZ(bU),ajaxTransport:bZ(bV),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?ca(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=cb(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bI.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bH,"").replace(bM,bX[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bQ),d.crossDomain==null&&(r=bS.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bX[1]&&r[2]==bX[2]&&(r[3]||(r[1]==="http:"?80:443))==(bX[3]||(bX[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bU,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bL.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bN.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bR,"$1_="+x);d.url=y+(y===d.url?(bN.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bV,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bE,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq,cr=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){return this[0]?parseFloat(f.css(this[0],d,"padding")):null},f.fn["outer"+c]=function(a){return this[0]?parseFloat(f.css(this[0],d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); -------------------------------------------------------------------------------- /templates/activity-item.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | {% raw user_link(user) %} 5 | {% if action == "cooked" %} 6 | cooked {{ recipe["title"] }} 7 | {% else %} 8 | added {{ recipe["title"] }} to {{ user_possessive(user) }} cookbook 9 | {% end %} 10 | {{ locale.format_date(date, relative=True, shorter=True) }} 11 |
12 |
13 | -------------------------------------------------------------------------------- /templates/activity-stream.html: -------------------------------------------------------------------------------- 1 |
2 |

Recent activity

3 | {% for item in activity %} 4 | {% module ActivityItem(user=item["user"], recipe=item["recipe"], date=item["created"], action=item["action"]) %} 5 | {% end %} 6 |
7 | -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {% block title %}Social Cookbook{% end %} 5 | 6 | {% block head %}{% end %} 7 | 8 | 9 | {% block top %}{% end %} 10 | 22 |
23 | {% if error_message %} 24 |
{{ error_message }}
25 | {% end %} 26 | 27 |
{% block body %}{% end %}
28 |
29 |
30 |
31 |

Upload a Photo

32 |
33 |

Recipe photos must be at least 300 pixels tall and 300 pixels wide.

34 |
35 | 36 | 37 |
38 |
39 |
40 |
Uploading...
41 | 42 | 43 |
44 |
45 |
46 | 47 | 48 | {% block bottom %}{% end %} 49 | 50 | 51 | -------------------------------------------------------------------------------- /templates/category.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %}{{ category }} - Social Cookbook{% end %} 4 | 5 | {% block body %} 6 | 10 |
11 |

{{ category }}

12 | {% if recipes %} 13 |
14 | {% if friend_recipes %} 15 |

Recently added recipes

16 | {% end %} 17 | {% module RecipeClips(recipes) %} 18 |
19 | {% end %} 20 | {% if friend_recipes %} 21 |
22 |

Recipes from friends

23 | {% module RecipeClips(friend_recipes) %} 24 |
25 | {% end %} 26 |
27 | {% end %} 28 | 29 | {% block sidebar %} 30 |
31 | Add a new recipe 32 |
33 | {% module ActivityStream(num=10) %} 34 | {% end %} 35 | -------------------------------------------------------------------------------- /templates/cookbook.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %}{{ user["name"] }}'s Cookbook{% end %} 4 | 5 | {% block body %} 6 | 10 |
11 |

{{ user["name"] }}'s Cookbook

12 | {% module RecipeList(recipes) %} 13 |
14 | {% end %} 15 | 16 | {% block sidebar %} 17 |
18 | Add a new recipe 19 |
20 | {% module ActivityStream(num=10) %} 21 | {% end %} 22 | -------------------------------------------------------------------------------- /templates/edit.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block body %} 4 | 13 |
14 | {% if not recipe %} 15 |

Recipe Title

16 | {% end %} 17 | 18 |
Where did you find this recipe? What does it mean to you?
19 |

Personal Note

20 | 21 |
List each ingredient on a separate line.
22 |

Ingredients

23 | 24 |

Instructions

25 | 26 |

Category

27 |
28 | {% if categories %} 29 | 34 | New category 35 | {% else %} 36 | 37 | {% end %} 38 |
39 |
40 | 41 | 42 |
43 | {% if recipe %} 44 | 45 | {% end %} 46 |
47 | {% end %} 48 | 49 | {% block bottom %} 50 | 51 | {% end %} 52 | -------------------------------------------------------------------------------- /templates/facepile.html: -------------------------------------------------------------------------------- 1 |
2 | {% for friend in friends[:num] %}{% end %} 3 |
4 | -------------------------------------------------------------------------------- /templates/home-empty.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block body %} 4 |
5 |

Welcome to Social Cookbook

6 |

Social Cookbook enables you to store your recipes online, and it makes 7 | it easy to share your recipes with your friends and family and see the 8 | recipes your friends and family are cooking. When you add a recipe to 9 | your cookbook, your friends will also be able to see it, and they can 10 | clip the recipe into their own cookbooks. Likewise, you can add any of 11 | your friends' recipes to your own cookbook with a single click.

12 |

It looks like you are the first of your friends to join the site, 13 | so we don't have any recipes to suggest to you right now.

14 |

To get started, click the button below to add a recipe to your cookbook. 15 | It will be shared on your Facebook profile, and when your friends join 16 | the site, they will automatically see the recipe, and you can start 17 | sharing recipes with each other.

18 |

Happy cooking!

19 |
20 | Add a new recipe 21 |
22 |
23 | {% end %} 24 | -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block body %} 4 |
5 | {% if user_recent %} 6 |
7 |

Recently added recipes

8 | {% module RecipeClips(user_recent) %} 9 |
10 | {% end %} 11 | {% if friends_recent %} 12 |
13 |

Recipes from friends

14 | {% module RecipeClips(friends_recent) %} 15 |
16 | {% end %} 17 | {% if all_recipes %} 18 |
19 |

All my recipes

20 | {% module RecipeList(all_recipes) %} 21 |
22 | {% end %} 23 |
24 | {% end %} 25 | 26 | {% block sidebar %} 27 |
28 | Add a new recipe 29 |
30 | {% module ActivityStream(num=10) %} 31 | {% end %} 32 | -------------------------------------------------------------------------------- /templates/recipe-actions.html: -------------------------------------------------------------------------------- 1 |
2 | {% if clipped %} 3 | 4 |
Let your friends know you cooked this, and add it to 5 | your Facebook profile
6 | {% else %} 7 | 8 |
Put this recipe in your cookbook, and add it to your 9 | Facebook profile
10 | {% end %} 11 |
12 | -------------------------------------------------------------------------------- /templates/recipe-clips.html: -------------------------------------------------------------------------------- 1 |
2 | {% for i, recipe in enumerate(recipes) %} 3 | {% if i % 2 == 0 and i > 0 %}
{% end %} 4 |
5 | {% module RecipePhoto(recipe, width=150, height=150, href=reverse_url("recipe", recipe["slug"])) %} 6 |

{{ recipe["title"] }}

7 | {% module RecipeContext(recipe, facepile_size=3, friend_list_size=1) %} 8 |
9 | {% end %} 10 |
11 | -------------------------------------------------------------------------------- /templates/recipe-context.html: -------------------------------------------------------------------------------- 1 |
2 | {% module Facepile(friends + [current_user] if clipped else friends, num=facepile_size) %} 3 |
4 | {% if len(friends) == 1 %} 5 | {% raw user_link(friends[0]) %} {{ "also has" if clipped else "has" }} this recipe in {{ user_possessive(friends[0]) }} cookbook. 6 | {% else %} 7 | {% raw friend_list(friends, size=friend_list_size) %} {{ "also have" if clipped else "have" }} this recipe in their cookbooks. 8 | {% end %} 9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /templates/recipe-info.html: -------------------------------------------------------------------------------- 1 |
2 | {% module RecipeContext(recipe) %} 3 |
4 | {% if clip_count > 1 %} 5 |
{{ clip_count }} people have added this
6 | {% end %} 7 | {% if cook_count > 1 %} 8 |
{{ cook_count }} people have cooked this
9 | {% end %} 10 |
11 |
12 | -------------------------------------------------------------------------------- /templates/recipe-list.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | {% set i = 0 %} 4 | {% set extra_column = False %} 5 | {% set num_recipes = sum(len(r) for r in categories.values()) %} 6 | {% for category in sorted(categories.keys()) %} 7 | {% if len(categories) > 1 %} 8 |

{{ category }}

9 | {% end %} 10 |
    11 | {% for recipe in categories[category] %} 12 |
  • {{ recipe["title"] }}
  • 13 | {% set i += 1 %} 14 | {% end %} 15 |
16 | {% if i > num_recipes / 2 and not extra_column %} 17 | {% set extra_column = True %} 18 |
19 |
20 | {% end %} 21 | {% end %} 22 |
23 |
24 | 25 | -------------------------------------------------------------------------------- /templates/recipe-photo-upload.html: -------------------------------------------------------------------------------- 1 | Upload a photo 2 | 3 | -------------------------------------------------------------------------------- /templates/recipe-photo.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /templates/recipe.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %}{{ recipe["title"] }} - Social Cookbook{% end %} 4 | 5 | {% block head %} 6 | 7 | 8 | 9 | 10 | 11 | 12 | {% if recipe["description"] %} 13 | 14 | {% end %} 15 | {% end %} 16 | 17 | {% block body %} 18 | 23 |
24 |

{{ recipe["title"] }}

25 |
26 | {% module RecipePhoto(recipe, width=300, height=200, max_height=300) %} 27 | {% if current_user and recipe["author_id"] == current_user["id"] %} 28 | 32 | {% end %} 33 |
34 |
35 | {% if recipe["description"] %} 36 |
{% raw markdown(recipe["description"]) %}
37 | {% end %} 38 |
39 | 40 |
Added by {% raw user_link(recipe["author"]) %} {{ locale.format_date(recipe["created"], relative=True, shorter=True) }}
41 |
42 |
43 |
44 |
45 | {% if recipe["ingredients"] %} 46 |

Ingredients

47 |
{% raw markdown(recipe["ingredients"]) %}
48 | {% end %} 49 | {% if recipe["instructions"] %} 50 |

Instructions

51 |
{% raw markdown(recipe["instructions"]) %}
52 | {% end %} 53 | {% if options.comments %} 54 |

Comments

55 | 56 | {% end %} 57 |
58 |
59 | {% end %} 60 | 61 | {% block sidebar %} 62 | {% if current_user %} 63 | {% module RecipeActions(recipe) %} 64 | {% module RecipeInfo(recipe) %} 65 | {% module ActivityStream(num=6) %} 66 | {% end %} 67 | {% end %} 68 | 69 | {% block bottom %} 70 | {% if options.comments %} 71 |
72 | 73 | {% end %} 74 | {% end %} 75 | 76 | --------------------------------------------------------------------------------