Exemplo n.º 1
0
def renderHist(page_name):
    id = request.args.get('id')
    result = db.query(
        "select pages.pagename, content.content, content.timestamp from pages,content where pages.id = content.pageid and content.id = '%s'"
        % id).namedresult()[0]

    content = markdown.markdown(wiki_linkify(result.content))
    return render_template('one_hist_record.html',
                           name=result.pagename,
                           content=content,
                           timestamp=result.timestamp)
Exemplo n.º 2
0
def view_page(page_name):
    query = db.query("select * from page where title = '%s'" % page_name)
    result_list = query.namedresult()
    if len(result_list) > 0:
        page = result_list[0]
        wiki_linkify_content = wiki_linkify(page.content)
        return render_template('view.html',
                               page=page,
                               wiki_linkify_content=wiki_linkify_content)
    else:
        return render_template('placeholder.html', page_name=page_name)
Exemplo n.º 3
0
def render_history_page(page_name):
    history_id = int(request.form.get('id'))
    print history_id
    print "BOOOOOOOOOOOM"
    history_content = db.query(
        "select content from history where id = '%d' order by date_saved desc"
        % history_id).namedresult()[0].content
    history_content = wiki_linkify(history_content)
    history_content = markdown.markdown(history_content)
    return render_template('history_page.html',
                           page_name=page_name,
                           history_content=history_content)
Exemplo n.º 4
0
def show_page(page_id):
    """
    Shows the contents of a specific page
    """
    page = models.Page(page_id)
    page.content = wiki_linkify(page.content)
    page.content = Markup(markdown.markdown(page.content))
    return render_template("view.html", page_id=page.page_id, \
                        title=page.title, \
                        content=page.content,\
                        last_modified=page.last_modified,\
                        modified_by=page.modified_by)
Exemplo n.º 5
0
def display_page(page_name):
    query = db.query("select * from page where page_title = '%s'" % page_name)
    result = query.namedresult()
    if len(result) < 1:
        return render_template('placeholder.html', page_name=page_name)
    else:
        query2 = db.query("select * from page where page_title = '%s'" %
                          page_name)
        result2 = query2.namedresult()
        # page_name = result2[0].page_title
        page_content = result2[0].content
        print "PAGE CONTENT %r" % page_content
        wiki_content = markdown.markdown(wiki_linkify(page_content))
        author = result2[0].author
        author = markdown.markdown(wiki_linkify(author))
        print "string %r" % wiki_content
        return render_template('pagename.html',
                               page_name=page_name,
                               content=wiki_content,
                               page_content=page_content,
                               author=author)
Exemplo n.º 6
0
def render_page(page_name):
    query = db.query("select * from pages where title = '%s'" % page_name)
    if len(query.namedresult()) > 0:
        query = query.namedresult()[0]
        pages_id = query.id
        newest_content = db.query(
            "select content from history where pages_id = '%d' order by date_saved desc"
            % pages_id).namedresult()[0].content
        newest_content = wiki_linkify(newest_content)
        newest_content = markdown.markdown(newest_content)
        return render_template('existing_page.html',
                               page_name=page_name,
                               newest_content=newest_content)
    else:
        return render_template('placeholder.html', page_name=page_name)
Exemplo n.º 7
0
def view_page(page_name):
    query = db.query("select * from page where title = $1", page_name)
    result_list = query.namedresult()
    if len(result_list) > 0:
        print result_list
        page_content = result_list[0].page_content
        page_content = page_content.replace('<', '&lt;').replace('>', '&gt;')
        page_content = wiki_linkify(page_content)
        parsed_content = Markup(markdown.markdown(page_content))

        print page_content
        return render_template('view.html',
                               page_name=page_name,
                               page_content=parsed_content)

    else:
        return render_template('placeholder.html', page_name=page_name)
Exemplo n.º 8
0
def wiki(page_name):
    # id = int(request.form.get('id'))

    #since there are multipule content pages you have to select from page_id in descending order to get the newest one
    query = db.query(
        "select title.id as title_id, page.id as page_id, title.title, page.page_content from page inner join title on page.title_id = title.id where title = $1 order by page_id desc",
        page_name)
    result_list = query.namedresult()
    if len(result_list) > 0:
        wiki_page = result_list[0]
        wiki_linkify_content = markdown.markdown(
            wiki_linkify(wiki_page.page_content))
        return render_template('view.html',
                               title=page_name,
                               page_name=page_name,
                               wiki_page=wiki_page,
                               wiki_linkify_content=wiki_linkify_content)
    else:
        return render_template('placeholder.html',
                               title=page_name,
                               page_name=page_name)
Exemplo n.º 9
0
def place_holder(page_name):
    # Query database looking for existing information for the page called by the user
    query = db.query("select * from page where title = $1",
                     page_name).namedresult()
    all_pages_query = db.query(
        "select title from page order by title;").namedresult()
    print "\n\nAll pages query: %r\n\n" % all_pages_query
    # No information was found in the database for the page
    if len(query) == 0:
        return render_template("placeholderpage.html",
                               page_name=page_name,
                               query=query,
                               all_pages_query=all_pages_query)
    # Information was found in the database for the page
    else:
        query = query[0]
        print query
        # Query database looking for historical information for the page called by the user
        query_history = db.query(
            "select * from page_history where page_id = $1 order by version_number DESC;",
            query.id).namedresult()
        print query_history
        page_content = query.page_content
        wiki_linkified_content = wiki_linkify(page_content)

        if len(query_history) > 0:
            return render_template(
                "placeholderpage.html",
                page_name=page_name,
                query=query,
                page_content=Markup(markdown.markdown(wiki_linkified_content)),
                query_history=query_history,
                all_pages_query=all_pages_query)
        else:
            return render_template(
                "placeholderpage.html",
                page_name=page_name,
                query=query,
                page_content=Markup(markdown.markdown(wiki_linkified_content)),
                all_pages_query=all_pages_query)
Exemplo n.º 10
0
def display_page(page_name):
    query = db.query("select * from page where page_title = $1", page_name)
    result = query.namedresult()
    if len(result) < 1:
        return render_template('placeholder.html', page_name=page_name)
    else:
        query2 = db.query(
            "select page.page_title, content.timestamp, content.content, content.author from page, content where page.id = content.page_id and page.page_title = $1 order by timestamp DESC",
            page_name)
        result2 = query2.namedresult()
        # page_name = result2[0].page_title
        page_content = result2[0].content
        # print "PAGE CONTENT %r" % page_content
        wiki_content = markdown.markdown(wiki_linkify(page_content))
        author = result2[0].author
        # author = markdown.markdown(wiki_linkify(author))
        # print "string %r" % wiki_content
        return render_template('pagename.html',
                               page_name=page_name,
                               content=wiki_content,
                               page_content=page_content,
                               author=author)
Exemplo n.º 11
0
def render_placeholder(page_name):
    query = db.query(
        "select pages.id, pages.pagename, content.content, content.timestamp as ts from pages,content where content.pageid = pages.id and pages.pagename = '%s' order by content.timestamp desc limit 1"
        % page_name)
    # query = db.query("select pages.id, pages.pagename, content.content, content.timestamp as ts from pages,content where content.pageid = pages.id and pages.pagename = $1 order by content.timestamp desc limit 1", page_name)
    results = query.namedresult()
    # print "Query: %r" % query
    is_available = False
    # print "Length: %d" % len(query.namedresult())
    if len(results) < 1:
        is_available = True
        db.insert('pages', {'pagename': page_name})
        newid = db.query("select * from pages where pages.pagename = '%s'" %
                         page_name).namedresult()[0].id
        db.insert(
            'content', {
                'pageid': newid,
                'content': "Page Created",
                'timestamp': time.strftime('%Y-%m-%d %H:%M:%S',
                                           time.localtime())
            })

        wiki_page = db.query(
            "select pages.id, pages.pagename, content.pageid, content.content, content.timestamp as ts from pages, content where pages.id = content.pageid and pages.pagename = '%s'"
            % page_name).namedresult()[0]
    else:
        wiki_page = results[0]
    # if page_name in db.('wiki',)
    # db.insert('wiki', pagename=page_name,content="")
    timestamp = wiki_page.ts
    content = markdown.markdown(wiki_linkify(wiki_page.content))
    return render_template('placeholder.html',
                           page_name=page_name,
                           is_available=is_available,
                           wiki_linkify=wiki_linkify,
                           content=content,
                           markdown=markdown,
                           wiki_page=wiki_page,
                           timestamp=timestamp)
Exemplo n.º 12
0
def render_page_name(page_name):
    query = db.query(
        "select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1"
        % page_name)
    wiki_page = query.namedresult()
    has_content = False
    page_is_taken = False
    if len(wiki_page) < 1:
        content = ""
    else:
        page_is_taken = True
        content = wiki_page[0].content
    if len(content) > 0:
        has_content = True
    else:
        pass
    content = markdown.markdown(wiki_linkify(content))
    return render_template('pageholder.html',
                           page_is_taken=page_is_taken,
                           page_name=page_name,
                           markdown=markdown,
                           wiki_linkify=wiki_linkify,
                           has_content=has_content,
                           content=content)
Exemplo n.º 13
0
def camel(word):
    return wiki_linkify(word)