def GET(self): user = xauth.current_name() key = xutils.get_argument("key", "") from_ = xutils.get_argument("from") show_tab = (xutils.get_argument("show_tab") != "false") if key != None and key != "": if key[0] == '#': # 精确搜索 default_content = key else: default_content = "#%s# " % key else: default_content = "" stat = MSG_DAO.get_message_stat(user) stat = format_message_stat(stat) return xtemplate.render("message/message.html", show_aside=False, show_tab=show_tab, category="message", search_action="/message", html_title=T("待办"), search_placeholder=T("搜索任务和便签"), default_content=default_content, message_stat=stat, key=key, from_=from_)
def GET(self): type = xutils.get_argument("type", self.default_type) parent_id = xutils.get_argument("parent_id") key = xutils.get_argument("key", "") title = T("最新笔记") show_create = True if type == "public": title = T("公共笔记") show_create = False else: xauth.check_login() if type == "gallery": title = T("相册") file = None if parent_id != None: file = NOTE_DAO.get_by_id(parent_id) title = file.name return xtemplate.render("note/timeline.html", title=title, type=type, file=file, key=key, show_create=show_create, search_action="/note/timeline", search_placeholder=T("搜索笔记"), show_aside=False)
def get_heading_by_type(type): if type == "group": return T("创建笔记本") if type == "gallery": return T("创建相册") if type == "csv": return T("创建表格") return T("创建笔记")
def get_parent_link(user_name, type, priority=0): if priority < 0: return PathLink(T("Archived_Project"), "/note/archived") if type == "default" or type == "root_notes": return PathLink(u"项目", xuserconfig.get_project_path(user_name)) if type == "public": return None return PathLink(T("NoteIndex"), "/note/index")
def GET(self): type = xutils.get_argument("type") title = T("时光轴") if type == "public": title = T("公共笔记") if type == "gallery": title = T("相册") return xtemplate.render("note/tools/timeline.html", title=title, show_aside=False)
def GET(self): from .dao import count_message return xtemplate.render("message/message.html", show_aside=False, category="message", search_action="/message", html_title=T("待办"), search_placeholder=T("搜索目标"), count_message=count_message, key=xutils.get_argument("key", ""))
def GET(self, orderby="edit", show_notice=False): if not xauth.has_login(): raise web.seeother("/note/public") if xutils.sqlite3 is None: raise web.seeother("/fs_list") days = xutils.get_argument("days", 30, type=int) page = xutils.get_argument("page", 1, type=int) pagesize = xutils.get_argument("pagesize", xconfig.PAGE_SIZE, type=int) page = max(1, page) offset = max(0, (page - 1) * pagesize) limit = pagesize time_attr = "ctime" creator = xauth.get_current_name() if orderby == "viewed": html_title = "Recent Viewed" files = xutils.call("note.list_recent_viewed", creator, offset, limit) time_attr = "atime" elif orderby == "created": html_title = "Recent Created" files = xutils.call("note.list_recent_created", None, offset, limit) time_attr = "ctime" else: html_title = "Recent Updated" files = xutils.call("note.list_recent_edit", None, offset, limit) time_attr = "mtime" groups = xutils.call("note.list_group", creator) count = xutils.call("note.count_user_note", creator) return xtemplate.render("note/recent.html", html_title=html_title, pathlist=[ Storage(name=T(html_title), type="group", url="/note/recent_" + orderby) ], file_type="group", files=files, file=Storage(name=T(html_title), type="group"), groups=groups, show_notice=show_notice, show_mdate=True, show_groups=False, show_aside=True, page=page, time_attr=time_attr, page_max=math.ceil(count / xconfig.PAGE_SIZE), page_url="/note/recent_%s?page=" % orderby)
def GET(self): source = xutils.get_argument("source") page = 1 limit = xconfig.PAGE_SIZE offset = (page-1)*limit files = load_note_index(xauth.current_name()) amount = len(files) if source == "group": show_path_list = False show_parent_link = True else: show_path_list = False show_parent_link = False return xtemplate.render("note/page/note_index.html", pathlist = [PathNode(TYPES_NAME, "/note/types")], html_title = T("索引"), file_type = "group", files = files, cards = files, show_path_list = show_path_list, show_parent_link = show_parent_link, show_next = True, show_size = True, **SEARCH_DOC_DICT)
def GET(self): type = xutils.get_argument("type", self.default_type) parent_id = xutils.get_argument("parent_id", "") key = xutils.get_argument("key", "") title = u"最新笔记" show_create = True if type == "public": show_create = False else: xauth.check_login() title = NOTE_TYPE_DICT.get(type, u"最新笔记") search_title = u"笔记" file = NOTE_DAO.get_by_id(parent_id) if file != None: title = file.name search_title = file.name return xtemplate.render("note/page/timeline.html", title = title, type = type, file = file, key = key, show_create = show_create, search_action = "/note/timeline", search_placeholder = T(u"搜索" + search_title), search_ext_dict = dict(parent_id = parent_id), show_aside = False)
def GET(self): source = xutils.get_argument("source") page = 1 limit = xconfig.PAGE_SIZE offset = (page - 1) * limit files = load_note_tools(xauth.current_name()) amount = len(files) if source == "group": show_path_list = False show_parent_link = True else: show_path_list = False show_parent_link = False return xtemplate.render(VIEW_TPL, pathlist=[PathNode(TYPES_NAME, "/note/types")], html_title=T("索引"), file_type="group", files=files, show_path_list=show_path_list, show_parent_link=show_parent_link, show_next=True, show_size=True, search_action="/note/timeline", search_placeholder="搜索笔记")
def GET(self): user_name = xauth.current_name() year = xutils.get_argument("year", time.strftime("%Y")) month = xutils.get_argument("month", time.strftime("%m")) if len(month) == 1: month = '0' + month dirname = os.path.join(xconfig.DATA_DIR, "files", user_name, year, month) pathlist = [] for root, dirs, files in os.walk(dirname): for fname in files: fpath = os.path.join(root, fname) pathlist.append(fpath) pathlist = sorted(pathlist) return xtemplate.render("fs/fs_upload.html", show_aside=False, html_title=T("文件"), pathlist=pathlist, year=int(year), month=int(month), path=dirname, dirname=dirname, get_webpath=get_webpath, upload_link_by_month=upload_link_by_month, get_display_name=get_display_name)
class RemovedHandler(BaseTimelineHandler): title = T("回收站") note_type = "removed" @xauth.login_required() def GET_old(self): page = xutils.get_argument("page", 1, type=int) user_name = xauth.current_name() limit = xconfig.PAGE_SIZE offset = (page - 1) * limit amount = NOTE_DAO.count_removed(user_name) files = NOTE_DAO.list_removed(user_name, offset, limit) parent = PathNode(TYPES_NAME, "/note/types") return xtemplate.render( VIEW_TPL, pathlist=[parent, PathNode(T("回收站"), "/note/removed")], file_type="group", files=files, page=page, show_aside=True, show_mdate=True, page_max=math.ceil(amount / 10), page_url="/note/removed?page=")
def GET(self): user_name = xauth.current_name() xmanager.add_visit_log(user_name, "/fs_upload") year = xutils.get_argument("year", time.strftime("%Y")) month = xutils.get_argument("month", time.strftime("%m")) if len(month) == 1: month = '0' + month dirname = os.path.join(xconfig.DATA_DIR, "files", user_name, "upload", year, month) pathlist = fsutil.listdir_abs(dirname) return xtemplate.render("fs/fs_upload.html", show_aside=False, html_title=T("文件"), pathlist=pathlist, year=int(year), month=int(month), path=dirname, dirname=dirname, get_webpath=get_webpath, upload_link_by_month=upload_link_by_month, get_display_name=get_display_name)
def __init__(self, tag, size): self.type = type self.size = size self.url = "/message?tag=" + tag self.priority = 0 self.show_next = True self.is_deleted = 0 self.name = "Message" self.icon = "fa-file-text-o" self.category = None if tag == "log": self.name = T("memo") self.icon = "fa-file-text-o" if tag == "task": self.name = T("任务") self.icon = "fa-calendar-check-o"
def GET(self): user_name = xauth.current_name() return xtemplate.render("search/page/search_history.html", show_aside=False, recent=list_search_history(user_name), html_title="Search", files=[], search_action="/note/timeline", search_placeholder=T(u"搜索笔记"))
def GET(self): user = xauth.current_name() stat = MSG_DAO.get_message_stat(user) stat = format_message_stat(stat) return xtemplate.render("message/calendar.html", show_aside=False, message_stat=stat, search_action="/message", search_placeholder=T("搜索待办事项"))
def search(ctx): """搜索Python文档""" if not xauth.is_admin(): return name = ctx.groups[0] if name in sys.modules: item = SearchResult() item.name = T("Python Document") + " - %s" % name item.url = "/system/document?name=%s" % name item.content = "" ctx.tools.append(item)
def GET(self): user = xauth.current_name() key = xutils.get_argument("key", "") if key != None and key != "": default_content = "#%s# " % key else: default_content = "" stat = MSG_DAO.get_message_stat(user) stat = format_message_stat(stat) return xtemplate.render("message/message.html", show_aside = False, category = "message", search_action = "/message", html_title = T("待办"), search_placeholder = T("搜索待办"), default_content = default_content, message_stat = stat, key = key)
def __init__(self, name, url, icon = "fa-cube", size = None): self.type = "link" self.name = T(name) self.url = url self.icon = icon self.size = size self.priority = 0 self.ctime = "" self.hide = False self.show_next = True self.is_deleted = 0
def GET(self): user_name = xauth.current_name() plugins = PLUGIN.find_plugins("note") template = "note/page/note_tools.html" xmanager.add_visit_log(user_name, "/note/tools") return xtemplate.render(template, html_title=T("笔记工具"), plugins=plugins, search_type="plugin")
def __init__(self, tag, size): self.type = type self.size = size self.url = "/message?tag=" + tag self.priority = 0 self.show_next = True self.is_deleted = 0 if tag == "log": self.name = T("memo") self.icon = "fa-file-text-o"
def GET(self): type = xutils.get_argument("type", self.note_type) parent_id = xutils.get_argument("parent_id", "") key = xutils.get_argument("key", "") title = u"最新笔记" # 检查登录态 if self.check_login: xauth.check_login() if type == "search" and key == "": raise web.found("/search") user_name = xauth.current_name() title = NOTE_TYPE_DICT.get(type, u"最新笔记") title_link = None note_priority = 0 search_title = u"笔记" file = NOTE_DAO.get_by_id(parent_id) xmanager.add_visit_log(user_name, "/note/%s" % self.note_type) if file != None: # title = file.name title = "笔记目录" search_title = file.name title_link = PathLink(file.name, file.url) note_priority = file.priority pathlist = [] parent_link = get_parent_link(user_name, type, note_priority) if parent_link != None: pathlist.append(parent_link) if title_link != None: pathlist.append(title_link) return xtemplate.render("note/page/timeline.html", title=title, type=type, file=file, key=key, pathlist=pathlist, show_create=self.show_create, search_action="/note/timeline", search_placeholder=T(u"搜索" + search_title), search_ext_dict=dict(parent_id=parent_id), parent_link=parent_link, title_link=title_link, CREATE_BTN_TEXT_DICT=CREATE_BTN_TEXT_DICT, show_aside=False)
def GET(self): page = xutils.get_argument("page", 1, type=int) user_name = xauth.current_name() limit = xconfig.PAGE_SIZE offset = (page - 1) * limit amount = xutils.call("note.count_removed", user_name) files = xutils.call("note.list_removed", user_name, offset, limit) return xtemplate.render(VIEW_TPL, pathlist=[PathNode(T("回收站"), "/note/removed")], file_type="group", files=files, page=page, show_aside=True, show_mdate=True, page_max=math.ceil(amount / 10), page_url="/note/removed?page=")
def GET(self): key = xutils.get_argument("key") user_name = xauth.current_name() user_dir = os.path.join(xconfig.UPLOAD_DIR, user_name) find_key = "*" + key + "*" if find_key == "**": plist = [] else: plist = sorted(xutils.search_path(user_dir, find_key, "file")) return xtemplate.render("fs/fs_upload.html", show_aside=False, html_title=T("文件"), page="search", pathlist=plist, path=user_dir, dirname=user_dir, get_webpath=get_webpath, upload_link_by_month=upload_link_by_month, get_display_name=get_display_name)
def GET(self): return xtemplate.render("note/tools/timeline.html", title = T("公开笔记"), type = "public") # 老的分页逻辑 page = xutils.get_argument("page", 1, type=int) page = max(1, page) offset = (page - 1) * xconfig.PAGE_SIZE files = NOTE_DAO.list_public(offset, xconfig.PAGE_SIZE) count = NOTE_DAO.count_public() return xtemplate.render(VIEW_TPL, show_aside = True, pathlist = [Storage(name="公开笔记", url="/note/public")], file_type = "group", dir_type = "public", files = files, page = page, show_cdate = True, groups = NOTE_DAO.list_group(), page_max = math.ceil(count/xconfig.PAGE_SIZE), page_url = "/note/public?page=")
def __init__(self, name, url, icon="fa-cube", size=None, roles=None, category="000"): self.type = "link" self.name = T(name) self.url = url self.icon = icon self.size = size self.priority = 0 self.ctime = "" self.hide = False self.show_next = True self.is_deleted = 0 self.category = category # 角色 if roles is None: roles = ("admin", "user") self.roles = roles
def GET(self): mem_used = 0 sys_mem_used = 0 sys_mem_total = 0 thread_cnt = 0 formated_mem_size = 0 thread_cnt = len(threading.enumerate()) item_list = [ Item('软件版本', get_xnote_version()), Item('sqlite版本', sqlite3.sqlite_version if sqlite3 != None else '') ] return xtemplate.render( "settings/page/settings.html", show_aside=False, html_title=T("设置"), item_list=item_list, sys_mem_total=xutils.format_size(sys_mem_total), thread_cnt=thread_cnt, xconfig=xconfig, xnote_version=get_xnote_version(), start_time=xconfig.START_TIME, init_script_url=INIT_SCRIPT_URL)
def POST(self, method='POST'): name = xutils.get_argument("name", "") tags = xutils.get_argument("tags", "") key = xutils.get_argument("key", "") content = xutils.get_argument("content", "") type = xutils.get_argument("type", "md") format = xutils.get_argument("_format", "") parent_id = xutils.get_argument("parent_id", "0") if key == "": key = time.strftime("%Y.%m.%d") creator = xauth.current_name() note = Storage(name=name) note.atime = xutils.format_datetime() note.mtime = xutils.format_datetime() note.ctime = xutils.format_datetime() note.creator = creator note.parent_id = parent_id note.type = type note.content = content note.data = "" note.size = len(content) note.is_public = 0 note.priority = 0 note.version = 0 note.is_deleted = 0 code = "fail" error = "" try: if name == '': if method == 'POST': message = 'name is empty' raise Exception(message) else: f = xutils.call("note.get_by_name", name) if f != None: key = name message = u"%s 已存在" % name raise Exception(message) inserted_id = xutils.call("note.create", note) if format == "json": return dict(code="success", id=inserted_id) raise web.seeother("/note/view?id={}".format(inserted_id)) except web.HTTPError as e1: xutils.print_exc() raise e1 except Exception as e: xutils.print_exc() error = str(e) if format == 'json': return dict(code='fail', message=error) return xtemplate.render( "note/add.html", show_aside=True, key="", type=type, name=key, tags=tags, error=error, pathlist=[Storage(name=T("New_Note"), url="/note/add")], message=error, groups=xutils.call("note.list_group"), code=code)
def POST(self, method='POST'): name = xutils.get_argument("name", "") tags = xutils.get_argument("tags", "") key = xutils.get_argument("key", "") content = xutils.get_argument("content", "") type = xutils.get_argument("type", "md") format = xutils.get_argument("_format", "") parent_id = xutils.get_argument("parent_id", "0") if key == "": key = time.strftime("%Y.%m.%d") + dateutil.current_wday() type = NOTE_TYPE_MAPPING.get(type, type) creator = xauth.current_name() note = Storage(name = name) note.atime = xutils.format_datetime() note.mtime = xutils.format_datetime() note.ctime = xutils.format_datetime() note.creator = creator note.parent_id = parent_id note.type = type note.content = content note.data = "" note.size = len(content) note.is_public = 0 note.priority = 0 note.version = 0 note.is_deleted = 0 note.tags = textutil.split_words(tags) heading = T("创建笔记") code = "fail" error = "" ctx = Storage(method = method) try: if type not in VALID_NOTE_TYPE_SET: raise Exception(u"无效的类型: %s" % type) create_func = CREATE_FUNC_DICT.get(type, default_create_func) inserted_id = create_func(note, ctx) if format == "json": return dict(code="success", id = inserted_id, url = "/note/edit?id=%s" % inserted_id) if inserted_id != None: raise web.seeother("/note/edit?id={}".format(inserted_id)) except web.HTTPError as e1: xutils.print_exc() raise e1 except Exception as e: xutils.print_exc() error = xutils.u(e) if format == 'json': return dict(code = 'fail', message = error) heading = get_heading_by_type(type) return xtemplate.render("note/page/create.html", show_search = False, heading = heading, key = "", type = type, name = key, tags = tags, error = error, message = error, NOTE_TYPE_LIST = NOTE_TYPE_LIST, groups = NOTE_DAO.list_group(creator), code = code)
def get_heading_by_type(type): title = u"创建" + NOTE_TYPE_DICT.get(type, u"笔记") return T(title)