Beispiel #1
0
    def create_board_post(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'create'):
            return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
        user_data = web.input()
        comment = 1 if user_data.has_key('commentable') else 0
        write_by_other = 1 if user_data.has_key('writable') else 0
        indexable = 1 if user_data.has_key('indexable') else 0
        show_avatar = 1 if user_data.has_key('show_avatar') else 0

        owner_uid = user._get_uid_from_username(user_data.owner)
        if owner_uid < 0:
            return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error')
        if user_data.name.strip() == '':
            return util.render().error(error_message = _('NO_NAME_SPECIFIED'), help_context='error')
        if board_name == '^root':
            new_path = posixpath.join('/', user_data.name)
        else:
            new_path = posixpath.join('/', board_name, user_data.name)
        if board._get_board_id_from_path(new_path) > 0:
            return util.render().error(error_message = _('BOARD_EXISTS'), help_context='error')

        settings = dict(path=new_path, board_owner = owner_uid,
                cover = user_data.information,
                description = user_data.description,
                type = int(user_data.type),
                guest_write = write_by_other,
                can_comment = comment,
                indexable = indexable, show_avatar = show_avatar,
                current_uid = current_uid)
        ret = board.create_board(board_id, settings)
        if ret[0] == False:
            return util.render().error(error_message = ret[1] ,help_context = 'error')
        raise web.seeother(util.link('%s') % (new_path))
Beispiel #2
0
    def modify_post(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'modify'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        data = web.input()
        comment = 1 if data.has_key('commentable') else 0
        write_by_other = 1 if data.has_key('writable') else 0
        indexable = 1 if data.has_key('indexable') else 0
        show_avatar = 1 if data.has_key('show_avatar') else 0

        owner_uid = user._get_uid_from_username(web.input().owner)
        if owner_uid < 0:
            return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error')

        board_info = dict(path = data.path, name = data.name,
                owner = owner_uid, board_type = int(data.type),
                can_comment = comment, can_write_by_other = write_by_other,
                indexable = indexable, show_avatar = show_avatar,
                stylesheet = data.stylesheet,
                description = data.description,
                cover = data.information)
        result = board.board_edit(current_uid, board_id, board_info)
        if result[0] == False:
            return util.render().error(error_message = result[1], help_context='error')
        else:
            raise web.seeother(util.link('%s') % result[1])
Beispiel #3
0
    def write_post(self, board_name, board_id, current_uid = -1):
        a = dict(title = web.input().title, body = web.input().content)
        board_info = board.get_board_info(board_id)
        ret = article.write_article(current_uid, board_id, a)
        if ret[0] == True:
            user.update_unreaded_articles_board(current_uid, board_id)
            user.read_article(current_uid, ret[1])

            fs = web.ctx.get('_fieldstorage')
            try:
                if fs.has_key('new_attachment'):
                    new_attachment = fs['new_attachment']
                    if type(new_attachment) == list:
                        for f in new_attachment:
                            attachment.add_attachment(ret[1], f.filename, f.value)
                    else:
                        try:
                            attachment.add_attachment(ret[1], new_attachment.filename, new_attachment.value)
                        except:
                            pass
            except:
                pass
            url = util.link('/%s/+read/%s' % (board_name, ret[1]))
            raise web.seeother(url)
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #4
0
def get_type(path):
    if path == '^root':
        path = '/'
    id = board._get_board_id_from_path(path)
    if id < 0:
        return -1
    data = board.get_board_info(id)
    return data.bType
Beispiel #5
0
 def favorites_get(self, current_uid = -1):
     fav_board = []
     for b in user.get_favorite_board(current_uid):
         fav_board.append(board.get_board_info(b.bSerial))
     return util.render().subboard_list(
         child_boards = fav_board, board_path = '',
         title=_('Favorite Boards'), board_desc = _('Favorite Boards'),
         list_type = _('Favorite Boards'))
Beispiel #6
0
    def search_get(self, board_name, board_id):
        board_info = board.get_board_info(board_id)
        if web.ctx.query == '':
            qs = dict()
        else:
            # XXX: http://bugs.python.org/issue8136
            qs = parse_qs(urllib.unquote(web.ctx.query[1:]).encode('latin-1').decode('utf-8'))

        if not qs.has_key('q'):
            return util.render().error(error_message = _('NO_KEYWORD_SPECIFIED'),
                    help_context = 'error')
        keyword = qs['q'][0]
        if qs.has_key('size'):
            page_size = int(qs['size'][0])
        else:
            page_size = config.page_size
        if qs.has_key('page'):
            page_no = int(qs['page'][0])
        else:
            page_no = 1
        author = False
        title = True
        body = True
        if qs.has_key('author'):
            author = True
            title = False
            body = False
        if qs.has_key('title'):
            title = True
            body = False
        if qs.has_key('body'):
            body = True
        ret = article.search_article(board_id, keyword, page_size, page_no,
                author, title, body)
        search_qs = "/+search?"
        if author:
            search_qs += "author=1&"
        if title:
            search_qs += "title=1&"
        if body:
            search_qs += "body=1&"
        if keyword:
            search_qs += "q=%s" % urllib.quote(keyword.encode('utf-8'))
        if ret[0]:
            return util.render().board(lang="ko",
                title = board_info.bName,
                board_path = board_info.bName[1:],
                board_desc = _('Search Results'),
                stylesheet = board_info.stylesheet,
                articles=ret[2], marked_articles = [],
                total_page = ret[1], page = page_no, feed = False,
                help_context = 'view_board', indent = False,
                author_checked = author, title_checked = title,
                body_checked = body, search_keyword = keyword,
                search_qs = search_qs)
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #7
0
 def summary_get(self, board_name, board_id):
     board_info = board.get_board_info(board_id)
     if board_id == 1:
         board_name = '^root'
     return util.render().board_summary(
             board_info = board_info,
             board_path = board_name,
             board_desc = board_info.bDescription, 
             stylesheet = board_info.stylesheet,
             title = _('Information - %s') % (board_info.bName))
Beispiel #8
0
    def GET(self, board_name):
        if board_name == '*' or board_name == '^root':
            v = board_actions()
            return v.subboard_list_get()

        board_id = board._get_board_id_from_path(board_name)
        if board_id < 0:
            #try to find regex match
            board_id = board._get_board_id_from_regex_path(board_name)
            if board_id < 0:
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error'))
            else:
                path = board._get_path_from_board_id(board_id)
                raise web.seeother(util.link(path))

        board_info = board.get_board_info(board_id)
        if board_info.bType == 0: # 디렉터리
            v = board_actions()
            return v.subboard_list_get(board_name, board_id)
        elif board_info.bType == 2: # 넘겨주기
            board_id = board._get_board_id_from_path(board_info.bDescription)
            if board_id < 0 or board_info.bDescription.strip() == '':
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_ALIAS'), help_context='error'))
            else:
                raise web.seeother(util.link(board_info.bDescription))

        #processing new_article
        if web.ctx.session.has_key('uid'):
            uid = web.ctx.session.uid
            user.update_unreaded_articles_board(uid, board_id)

        qs = web.ctx.query
        if len(qs) > 0:
            qs = qs[1:]
            qs = parse_qs(qs)


        t = article._get_total_page_count(board_id, config.page_size)
        if qs:
            page = int(qs['page'][0])
        else:
            page = t

        a = article.get_article_list(board_id, config.page_size, page)
        m = article.get_marked_article(board_id)

        return util.render().board(lang="ko",
            title = board_info.bName,
            board_path = board_info.bName[1:],
            board_desc = board_info.bDescription,
            stylesheet = board_info.stylesheet,
            articles=a, marked_articles = m,
            total_page = t, page = page, feed = True,
            help_context = 'board')
Beispiel #9
0
 def write_get(self, board_name, board_id, current_uid = -1):
     board_info = board.get_board_info(board_id)
     if board_info.bType != 1:
         raise web.notfound(util.render().error(error_message = _('CANNOT_WRITE_ON_THIS_BOARD'), help_context='error'))
     board_desc = board_info.bDescription
     user_info = user.get_user(current_uid)[1]
     return util.render().article_edit(
             title = _('Write article - %s') % (board_name),
             action='write', action_name = _('Write article'),
             board_path = board_name, board_desc = board_desc, lang="ko",
             stylesheet = board_info.stylesheet,
             body = '\n\n\n%s' % user_info['uSig'], help_context='article_edit')
Beispiel #10
0
    def comment_post(self, board_name, board_id, article_id, current_uid = -1):
        if not acl.is_allowed('board', board_id, current_uid, 'comment'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        comment = web.input().comment
        board_info = board.get_board_info(board_id)
        ret = article.write_comment(current_uid, board_id, article_id, comment)
        if ret[0] == True:
            user.update_unreaded_articles_board(current_uid, board_id)
            user.read_article(current_uid, ret[1])

            raise web.seeother(util.link('/%s/+read/%s') % (board_name, article_id))
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #11
0
 def modify_get(self, board_name, board_id, article_id, current_uid = -1):
     if not acl.is_allowed('article', article_id, current_uid, 'modify'):
         return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
     board_info = board.get_board_info(board_id)
     board_desc = board_info.bDescription
     article_ = article.get_article(board_id, article_id)
     uploads = attachment.get_attachment(article_id)
     return util.render().article_edit(
             title = _('Modify - /%s')% board_name,
             stylesheet = board_info.stylesheet,
             action='modify/%s' % article_id, 
             action_name = _('Modify article'),
             board_path = board_name, board_desc = board_desc,
             article_title = article_.aTitle, body = article_.aContent,
             attachment = uploads, help_context = 'article_edit')
Beispiel #12
0
    def modify_get(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'modify'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        if board_id == 1:
            board_name = '^root'
        default_referer = posixpath.join(util.link('/'), board_name, '+summary')

        return util.render().board_edit(
                action='modify', board_info = board_info,
                board_path = board_name, 
                board_desc = board_info.bDescription, 
                stylesheet = board_info.stylesheet,
                title = _('Modify information - %s') % (board_info.bName),
                referer = web.ctx.env.get('HTTP_REFERER', default_referer))
Beispiel #13
0
    def read_get(self, board_name, board_id, article_id):
        board_info = board.get_board_info(board_id)
        board_desc = board_info.bDescription
        a = article.get_article(board_id, article_id)
        comment = article.get_comment(article_id)

        #새글읽기 처리
        if web.ctx.session.has_key('uid'):
            uSerial = web.ctx.session.uid
            user.read_article(uSerial, article_id) 

        read_articles = web.cookies().get('read_articles')
        if read_articles:
            try:
                read_articles = [int(i) for i in read_articles.split(';')]
                if article_id not in read_articles:
                    article.increase_read_count(article_id)
                    read_articles.append(article_id)
            except ValueError:
                read_articles = []
        else:
            article.increase_read_count(article_id)
            read_articles = [article_id]
        read_articles.sort()
        read_articles = ';'.join(['%s' % i for i in read_articles])
        web.setcookie('read_articles', read_articles, 3600)

        prev_id = -1
        next_id = -1

        if not a:
            raise web.notfound(util.render().error(error_message = _('NO_SUCH_ARTICLE'), help_context='error'))
        if a.aIndex > 1:
            prev_id = article.get_article_id_by_index(board_id, a.aIndex - 1)
        if a.aIndex < article._get_article_count(board_id):
            next_id = article.get_article_id_by_index(board_id, a.aIndex + 1)
        page_no = article.get_page_by_article_id(board_id, article_id, config.page_size)
        uploads = attachment.get_attachment(article_id)
        thumbs = attachment.get_thumbnail(article_id, web.config.theme)

        return util.render().article(article = a,
            title = u"%s - %s" % (a.aIndex, a.aTitle),
            stylesheet = board_info.stylesheet,
            board_path = board_name, board_desc = board_desc,
            comments = comment, page_no = page_no,
            prev_id = prev_id, next_id = next_id, feed = True,
            attachment = uploads, thumbnail = thumbs,
            help_context = 'read_article')
Beispiel #14
0
 def subboard_list_get(self, board_name = '', board_id = 1):
     board_info = board.get_board_info(board_id)
     child_board = board.get_child(board_id)
     if board_name == "":
         board_name = _('Main menu')
         board_path = ""
     else:
         board_path = board_name
         if board_name[0] != '/':
             board_name = '/%s' % (board_name)
     return util.render().subboard_list(
             lang="ko",
             title = board_name,
             board_path = board_path,
             board_desc = board_info.bDescription,
             stylesheet = board_info.stylesheet,
             child_boards = child_board)
Beispiel #15
0
    def atom_get(self, board_name, board_id):
        if web.ctx.query == '':
            qs = dict()
            feed_size = config.feed_size
        else:
            qs = parse_qs(web.ctx.query[1:])
            feed_size = int(qs['size'][0])
        board_info = board.get_board_info(board_id)
        if board_info.bType == 0: # 디렉터리
            return

        date = datetime.today()
        articles = article.get_article_feed(board_id, feed_size)
        web.header('Content-Type', 'application/atom+xml')
        return render['default'].atom(board_path = board_name,
                board_desc = board_info.bDescription,
                articles=articles, today=date)
Beispiel #16
0
 def reply_get(self, board_name, board_id, article_id, current_uid = -1):
     if not acl.is_allowed('board', board_id, current_uid, 'write'):
         return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
     board_info = board.get_board_info(board_id)
     board_desc = board_info.bDescription
     user_info = user.get_user(current_uid)[1]
     article_ = article.get_article(board_id, article_id)
     quote_text = _('From %s\'s Article %s:') % (user._get_username_from_uid(article_.uSerial), util.remove_bracket(article_.aTitle))
     body = '\n\n\n[quote=%s]%s\n[/quote]\n\n%s' % (quote_text, article_.aContent, user_info.uSig)
     return util.render().article_edit(
             title = _('Reply - /%s') % board_name,
             stylesheet = board_info.stylesheet,
             action='reply/%s' % article_id, 
             action_name = _('Reply to the article'),
             board_path = board_name, board_desc = board_desc,
             body = body, article_title = article_.aTitle,
             help_context = 'article_edit')
Beispiel #17
0
    def modify_post(self, board_name, board_id, article_id, current_uid = -1):
        if not acl.is_allowed('article', article_id, current_uid, 'modify'):
            return util.render().error(error_message = _('NO_PERMISSION'), help_context='error')
        data = web.input(new_attachment= {})
        fs = web.ctx.get('_fieldstorage')
        try:
            if fs.has_key('delete'):
                to_delete = fs['delete']
                if type(to_delete) == list:
                    for f in to_delete:
                        attachment.remove_attachment(article_id, f.value)
                else:
                    try:
                        attachment.remove_attachment(article_id, to_delete.value)
                    except:
                        pass
            if fs.has_key('new_attachment'):
                new_attachment = fs['new_attachment']
                if type(new_attachment) == list:
                    for f in new_attachment:
                        attachment.add_attachment(article_id, f.filename, f.value)
                else:
                    try:
                        attachment.add_attachment(article_id, new_attachment.filename, new_attachment.value)
                    except:
                        pass
        except:
            pass

        mark_as_unreaded = web.input().has_key('unreaded')

        a = dict(title = data.title, body = data.content)
        board_info = board.get_board_info(board_id)
        ret = article.modify_article(current_uid, board_id, article_id, a, mark_as_unreaded)
        if ret[0] == True:
            raise web.seeother(util.link('/%s/+read/%s') % (board_name, ret[1]))
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #18
0
def traverse_board_path(path, theme=None):
    if path == '^root':
        path = '/'
    ret = ""
    id = board._get_board_id_from_path(path)
    while id != 1 and id > 0:
        i = board.get_board_info(id)
        if i.bType == 0:
            if theme:
                ret = '/<a class="dirlink" href="/%s%s">%s</a>' % (theme, i.bName, i.bName.split('/')[-1]) + ret
            else:
                ret = '/<a class="dirlink" href="%s">%s</a>' % (i.bName, i.bName.split('/')[-1]) + ret
        else:
            if theme:
                ret = '/<a class="boardlink" href="/%s%s">%s</a>' % (theme, i.bName, i.bName.split('/')[-1]) + ret
            else:
                ret = '/<a class="boardlink" href="%s">%s</a>' % (i.bName, i.bName.split('/')[-1]) + ret
        new_id = board.get_parent(id)
        if new_id == id:
            break
        id = new_id
#    ret = (u'<a class="dirlink" href="/">%s</a>' % _('Board')) + ret
    return ret
Beispiel #19
0
    def all_get(self, board_name, board_id, current_uid = -1):
        board_id = board._get_board_id_from_path(board_name)
        if board_id < 0:
            path = board._get_path_from_board_id(board_id)
            raise web.seeother(util.link(path))

        board_info = board.get_board_info(board_id)
        board_name = board_info.bName;

        if web.ctx.session.has_key('uid'):
            uid = web.ctx.session.uid
            user.update_unreaded_articles_board(uid, board_id)

        qs = web.ctx.query
        if len(qs) > 0:
            qs = qs[1:]
            qs = parse_qs(qs)

        t = article._get_recurse_page_count(board_name, config.page_size)
        if qs:
            page = int(qs['page'][0])
        else:
            page = t

        a = article.get_recurse_article_list(board_name, 
            config.page_size, page)
        m = article.get_marked_article(board_id)

        return util.render().board(lang="ko",
            title = board_info.bName,
            board_path = board_info.bName[1:],
            board_desc = board_info.bDescription,
            stylesheet = board_info.stylesheet,
            articles=a, marked_articles = m,
            total_page = t, page = page, feed = True,
            help_context = 'board')
Beispiel #20
0
 def reply_post(self, board_name, board_id, article_id, current_uid = -1):
     if not acl.is_allowed('board', board_id, current_uid, 'write'):
         return util.render().error(error_message = _('NO_PERMISSION'), help_context = 'error')
     reply = dict(title = web.input().title, body = web.input().content)
     board_info = board.get_board_info(board_id)
     ret = article.reply_article(current_uid, board_id, article_id, reply)
     if ret[0] == True:
         fs = web.ctx.get('_fieldstorage')
         try:
             if fs.has_key('new_attachment'):
                 new_attachment = fs['new_attachment']
                 if type(new_attachment) == list:
                     for f in new_attachment:
                         attachment.add_attachment(ret[1], f.filename, f.value)
                 else:
                     try:
                         attachment.add_attachment(ret[1], new_attachment.filename, new_attachment.value)
                     except:
                         pass
         except:
             pass
         raise web.seeother(util.link('/%s/+read/%s') % (board_name, ret[1]))
     else:
         return util.render().error(error_message = ret[1], help_context='error')
Beispiel #21
0
 def cover_get(self, board_name, board_id):
     board_info = board.get_board_info(board_id)
     return render['default'].cover(
             title = board_name,
             board_cover = board_info.bInformation)