def doCreate(self): target = self.request.get("datestamp") title = self.request.get("title") up = self.request.get("up") relative = self.request.get("relative") ctheme = None options = None # Handling custom themes or normal themes customTheme = self.request.get("customTheme") if customTheme: parser = safehtml.SafeHtmlParser() safe = parser.getSafeHtml(customTheme) ctheme = modelold.CustomTheme(html=safe, isTemplate=False) ctheme.put() else: options = self.request.get("music") + self.request.get("theme") if relative: self.redirect("/" + target + options + "/" + title) else: storedUrl = utils.storeUrl(self.request.url, target, options, title, ctheme, up, relative) self.redirect("/" + pb64.encodeB64Padless(storedUrl.counter))
def get(self, target, optionsStr, title): logging.info(">>> " + self.request.url + " >>>CountDownDMYHMS") # Expected format is DDMMYYYYHHMMSS (checked via main.py by a regexp anyway) day = target[:2] month = target[2:4] year = target[4:8] hour = target[8:10] minute = target[10:12] second = target[12:14] if utils.isValidDate(day, month, year, hour, minute, second): storedUrl = utils.storeUrl(self.request.url, target, optionsStr or "", title or "", None, None, None) ctheme = None isTemplatizedCTheme = False options = {} if storedUrl.customTheme: ctheme = storedUrl.customTheme.html isTemplatizedCTheme = storedUrl.customTheme.isTemplate else: options = themecontroller.getThemeOptions(optionsStr) jsdate = month + "/" + day + "/" + year + " " + hour + ":" + minute + ":" + second if title: title = title.strip() if title != '': title = urllib2.unquote(title.strip()) else: title = "" urlToShare = utils.getContextRootFromUrl(self.request.url) + "/" + pb64.encodeB64Padless(storedUrl.counter) data = { "dateObject" : { "day": day, "month": month, "year": year, "hour": hour, "minute": minute }, "jsdate": jsdate, "title": title, "options": options, "customTheme": ctheme, "isTemplateTheme": isTemplatizedCTheme, "form": {}, "up": storedUrl.up, "relative": storedUrl.relative, "shortUrl": urlToShare, "listOfThemes": themecontroller.getListOfThemes() } data["latestUrls"] = utils.getLatestUrls() data["popularUrls"] = utils.getMostPopulars() formData = utils.prepareFormData() data["form"].update(formData) pageContent = utils.getTemplateContent(os.path.join(os.path.dirname(__file__), "templates/main.html"), data) self.response.out.write(pageContent) else: # Error, the date has a valid format, but is not a real date self.redirect("/")