Example #1
0
def search_from_reference(text):
    """Convert a raw reference to a search query

    Called by the search engine to convert a raw reference:
    find rawref John, JINST 4 (1994) 45
    is converted to
    journal:"JINST,4,45"
    """
    field = ''
    pattern = ''

    kbs = get_kbs()
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(text, kbs)

    for elements in references:
        for el in elements:
            if el['type'] == 'JOURNAL':
                field = 'journal'
                pattern = CFG_JOURNAL_PUBINFO_STANDARD_FORM \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'p'), el['title']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'v'), el['volume']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'c'), el['page']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'y'), el['year'])
                break
            elif el['type'] == 'REPORTNUMBER':
                field = 'report'
                pattern = el['report_num']
                break

    return field, pattern.encode('utf-8')
Example #2
0
def search_from_reference(text):
    """Convert a raw reference to a search query

    Called by the search engine to convert a raw reference:
    find rawref John, JINST 4 (1994) 45
    is converted to
    journal:"JINST,4,45"
    """
    field = ''
    pattern = ''

    kbs = get_kbs()
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(text, kbs)

    for elements in references:
        for el in elements:
            if el['type'] == 'JOURNAL':
                field = 'journal'
                pattern = CFG_JOURNAL_PUBINFO_STANDARD_FORM \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'p'), el['title']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'v'), el['volume']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'c'), el['page']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'y'), el['year'])
                break
            elif el['type'] == 'REPORTNUMBER':
                field = 'report'
                pattern = el['report_num']
                break

    return field, pattern.encode('utf-8')
    def custom_summary(self, req, form):
        """Custom report page"""
        argd = wash_urlargd(form, {'query': (str, ""),
                                   'tag': (str, CFG_JOURNAL_TAG.replace("%", "p")),
                                   'title': (str, "Publications"),
                                   'ln': (str, CFG_SITE_LANG)})
        ln = argd['ln']
        user_info = collect_user_info(req)
        (auth_code, auth_msg) = acc_authorize_action(user_info, 'runwebstatadmin')
        if auth_code:
            return page_not_authorized(req,
                navtrail=self.navtrail % {'ln_link': (ln != CFG_SITE_LANG and '?ln=' + ln) or ''},
                text=auth_msg,
                navmenuid='custom query summary',
                ln=ln)

        return page(title="Custom query summary",
                    body=perform_display_custom_summary(argd, ln=ln),
                    navtrail="""<a class="navtrail" href="%s/stats/%s">Statistics</a>""" % \
                    (CFG_SITE_URL, (ln != CFG_SITE_LANG and '?ln=' + ln) or ''),
                    description="CDS, Statistics, Custom Query Summary",
                    keywords="CDS, statistics, custom query summary",
                    req=req,
                    lastupdated=__lastupdated__,
                    navmenuid='custom query summary',
                    language=ln)