Exemplo n.º 1
0
def format_element(bfo):
    """
    Formats comments header using the post's name and
    the date in which the comment was added
    """

    this_recid = bfo.control_field('001')

    post_recid = get_parent_post(this_recid)
    post_rec = BibFormatObject(post_recid)
    try:
        post_title = post_rec.fields('245__a')[0]
    except:
        post_title = 'Untitled'

    try:
        addition_date = bfo.fields('269__c')[0]
    except:
        addition_date = ""

    out = '<div id="top"><div id="topbanner">&nbsp;</div>'
    out += '<div id="mainmenu"><table width="100%">'
    out += '<tr><td class="left" style = "font-size: 1em;">Go to post: <a href="%s/record/%s?%s">%s</a>' % \
                (CFG_SITE_URL, post_recid, bfo.lang, post_title)

    out += '<td class="right">%s</td>' % addition_date
    out += '</td></tr></table></div></div>'
    out += '<div id="mainphoto"></div>'

    return out
Exemplo n.º 2
0
def format_element(bfo):
    """
    Creates a navigation for comments.
    """

    # get variables
    this_recid = bfo.control_field('001')
    try:
        this_content = bfo.fields('520__a')[0]
    except:
        return ""
    try:
        this_author = bfo.fields('100__a')[0]
    except:
        return ""

    this_limit_content = get_contextual_content(this_content,
                                                [],
                                                max_lines=2)[0]
    menu_recids = []
    current_language = bfo.lang

    post_recid = get_parent_post(this_recid)

    menu_recids = get_comments(post_recid, newest_first=True)

    try:
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"][current_language]
    except:
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"]['en']

    for recid in menu_recids:
        if str(this_recid) == str(recid):
            menu_out += '<div class="active"><div class="litem"><b>%s</b>: %s [...]</div></div>' % (this_author, this_limit_content)
        else:
            temp_rec = BibFormatObject(recid)
            content = temp_rec.fields('520__a')[0]
            limit_content = get_contextual_content(content,
                                                   [],
                                                   max_lines=1)[0]

            try:
                author = temp_rec.fields('100__a')[0]
            except:
                author = 'Anonymous'
            menu_out += '<div class="litem"><a href="%s/record/%s%s"><b>%s</b>: %s [...]</a></div>' % (CFG_SITE_URL,
                                                                                                recid,
                                                                                                (bfo.lang=="fr") and "?ln=fr" or "?ln=en",
                                                                                                author, limit_content)
            

        
    return menu_out
Exemplo n.º 3
0
def format_element(bfo):
    """
    Displays the description of how users should cite
    any content of the archive. The citation includes:
    For blogs: "title".
    (record_creation_date). record_url
    Retrieved from the original "original_url"
    For blog posts: author. "title". Blog: "blog_title".
    (record_creation_date). record_url
    Retrieved from the original "original_url"
    For comments: author. Blog post: "post_title".
    (record_creation_date). record_url
    Retrieved from the original "original_url"
    """

    coll = bfo.fields('980__a')[0]
    recid = bfo.control_field('001')

    # let's get the fields we want to show
    if coll in ["BLOGPOST", "COMMENT"]:
        author = bfo.fields('100__a')[0]
        try:
            original_creation_date = bfo.fields('269__c')[0]
        except:
            original_creation_date = ""

    try:
        title = bfo.fields('245__a')[0]
    except:
        title = "Untitled"

    try:
        original_url = bfo.fields('520__u')[0]
    except:
        raise Exception("URL not found")

    # creation date of a record
    record_creation_date = get_creation_date(recid)
    # url in the archive
    record_url = CFG_SITE_URL + "/record/" + recid

    if coll == "BLOGPOST":
        # we will also show the blog's title of 
        # the corresponding blog post
        blog_recid = get_parent_blog(recid)
        blog_bfo = BibFormatObject(blog_recid)
        try:
            blog_title = blog_bfo.fields('245__a')[0]
        except:
            blog_title = 'Untitled'

        description = """<table style="border:1px solid black;"><tr><td>\
        <span><b>%s</b>. '%s'. Blog: '%s'. </br> \
        (%s). <i>'%s'</i> </br> \
        Retrieved from the original <i>'%s'</i><span></td></tr></table>""" \
        % (author, title, blog_title, record_creation_date, record_url, original_url)

    elif coll == "COMMENT":
        # we will also show the post's title of
        # the corresponding comment
        post_recid = get_parent_post(recid)
        post_bfo = BibFormatObject(post_recid)
        try:
            post_title = post_bfo.fields('245__a')[0]
        except:
            post_title = 'Untitled'

        description = """<table style="border:1px solid black;"><tr><td>\
        <span><b>%s. </b>Blog post: '%s'.</br> \
        (%s). <i>'%s'</i> </br> \
        Retrieved from the original <i>'%s'</i><span></td></tr></table>""" \
        % (author, post_title, record_creation_date, record_url, original_url)

    else: # coll == "BLOG"
        description = """<table style="border:1px solid black;"><tr><td>\
        <span>'%s' </br> \
        (%s). <i>'%s'</i> </br> \
        Retrieved from the original <i>'%s'</i><span></td></tr></table>""" \
        % (title, record_creation_date, record_url, original_url)

    out = """
        <script type="text/javascript">
        function displayCitationDescription(){
            var description = document.getElementById('description');
            var citation_link = document.getElementById('citation_link');
            if (description.style.display == 'none'){
                description.style.display = '';
                citation_link.innerHTML = "Hide citation description"
            } else {
                description.style.display = 'none';
                citation_link.innerHTML = "How to cite this"
            }
        }
        </script>
        """

    out += '<span id="description" style="">' + description + '</span>'
    out += '<a class="moreinfo" id="citation_link" \
            href="javascript:void(0)" onclick="displayCitationDescription()""></a>'
    out += '<script type="text/javascript">displayCitationDescription()</script>'

    return out