def update(self, req, form): argd = wash_urlargd( form, { "name": (str, None), "freq": (str, None), "notif": (str, None), "idb": (int, None), "idq": (int, None), "old_idb": (int, None), }, ) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/update" % (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url( req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd( { "referer": "%s/youralerts/update%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln": argd["ln"], }, {}, ), ), ) # load the right language _ = gettext_set_language(argd["ln"]) user_info = collect_user_info(req) if not user_info["precached_usealerts"]: return page_not_authorized(req, "../", text=_("You are not authorized to use alerts.")) try: html = webalert.perform_update_alert( argd["name"], argd["freq"], argd["notif"], argd["idb"], argd["idq"], argd["old_idb"], uid, ln=argd["ln"] ) except webalert.AlertError, msg: return page( title=_("Error"), body=webalert_templates.tmpl_errorMsg(ln=argd["ln"], error_msg=msg), navtrail="""<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % {"sitesecureurl": CFG_SITE_SECURE_URL, "ln": argd["ln"], "account": _("Your Account")}, description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME), uid=uid, language=argd["ln"], req=req, lastupdated=__lastupdated__, navmenuid="youralerts", )
def display(self, req, form): """Display search history page. A misnomer.""" argd = wash_urlargd(form, {'p': (str, "n") }) uid = getUid(req) # load the right language _ = gettext_set_language(argd['ln']) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/display" % \ (CFG_SITE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/youralerts/display%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) if argd['p'] == 'y': _title = _("Popular Searches") else: _title = _("Your Searches") # register event in webstat if user_info['email']: user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["display", "", user_str]) except: register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'") return page(title=_title, body=webalert.perform_display(argd['p'], uid, ln=argd['ln']), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%s Personalize, Display searches") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts', secure_page_p=1)
def index(self, req, form): """Index page.""" argd = wash_urlargd(form, {'page': (int, 1), 'format': (str, "rc"), 'order_by': (str, "lcf"), 'per_page': (str, "all"), }) # TODO: support also "reviews", by adding new option to show/hide them if needed uid = getUid(req) # load the right language _ = gettext_set_language(argd['ln']) # Is site ready to accept comments? if not CFG_WEBCOMMENT_ALLOW_COMMENTS or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/yourcomments" % \ (CFG_SITE_SECURE_URL,), text="Comments are currently disabled on this site", navmenuid="yourcomments") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/yourcomments%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) user_info = collect_user_info(req) if not user_info['precached_sendcomments']: # Maybe we should still authorize if user submitted # comments in the past? return page_not_authorized(req, "../", \ text = _("You are not authorized to use comments.")) return page(title=_("Your Comments"), body=perform_display_your_comments(user_info, page_number=argd['page'], selected_order_by_option=argd['order_by'], selected_display_number_option=argd['per_page'], selected_display_format_option=argd['format'], ln=argd['ln']), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%s View your previously submitted comments") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts', secure_page_p=1)
def list(self, req, form): argd = wash_urlargd(form, {}) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/list" % (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url( req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd( { "referer": "%s/youralerts/list%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln": argd["ln"], }, {}, ), ), ) # load the right language _ = gettext_set_language(argd["ln"]) user_info = collect_user_info(req) if not user_info["precached_usealerts"]: return page_not_authorized(req, "../", text=_("You are not authorized to use alerts.")) # register event in webstat if user_info["email"]: user_str = "%s (%d)" % (user_info["email"], user_info["uid"]) else: user_str = "" try: register_customevent("alerts", ["list", "", user_str]) except: register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'") return page( title=_("Your Alerts"), body=webalert.perform_list_alerts(uid, ln=argd["ln"]), navtrail="""<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % {"sitesecureurl": CFG_SITE_SECURE_URL, "ln": argd["ln"], "account": _("Your Account")}, description=_("%s Personalize, Display alerts") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd["ln"], CFG_SITE_NAME), uid=uid, language=argd["ln"], req=req, lastupdated=__lastupdated__, navmenuid="youralerts", )
def modify(self, req, form): argd = wash_urlargd(form, {'idq': (int, None), 'old_idb': (int, None), 'name': (str, ""), 'freq': (str, "week"), 'notif': (str, "y"), 'idb': (int, 0), 'error_msg': (str, ""), }) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/modify" % \ (CFG_SITE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/youralerts/modify%s" % ( CFG_SITE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) # load the right language _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) try: html = webalert.perform_input_alert("update", argd['idq'], argd['name'], argd['freq'], argd['notif'], argd['idb'], uid, argd['old_idb'], ln=argd['ln']) except webalert.AlertError, msg: return page(title=_("Error"), body=webalert_templates.tmpl_errorMsg(ln=argd['ln'], error_msg=msg), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts')
def tmpl_navtrailbox_body(self, ln, title, previous_links, separator, prolog, epilog): """Create navigation trail box body Parameters: - 'ln' *string* - The language to display - 'title' *string* - page title; - 'previous_links' *string* - the trail content from site title until current page (both ends exclusive) - 'prolog' *string* - HTML code to prefix the navtrail item with - 'epilog' *string* - HTML code to suffix the navtrail item with - 'separator' *string* - HTML code that separates two navtrail items Output: - text containing the navtrail Note: returns empty string for Home page. (guessed by title). """ # load the right message language _ = gettext_set_language(ln) out = "" if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): # return empty string for the Home page return out else: out += create_html_link(CFG_SITE_URL, {'ln': ln}, _("Home"), {'class': 'navtrail'}) if previous_links: if out: out += separator out += previous_links if title: if out: out += separator if title == CFG_SITE_NAME_INTL.get( ln, CFG_SITE_NAME): # hide site name, print Home instead out += cgi.escape(_("Home")) else: out += cgi.escape(title) return cgi.escape(prolog) + out + cgi.escape(epilog)
def list(self, req, form): argd = wash_urlargd(form, {}) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/list" % \ (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/youralerts/list%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) # load the right language _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) # register event in webstat if user_info['email']: user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["list", "", user_str]) except: register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'") return page(title=_("Your Alerts"), body=webalert.perform_list_alerts(uid, ln = argd['ln']), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%(site)s Personalize, Display alerts", site=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), keywords=_("%(site)s, personalize", site=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts')
def tmpl_navtrailbox_body(self, ln, title, previous_links, separator, prolog, epilog): """Create navigation trail box body Parameters: - 'ln' *string* - The language to display - 'title' *string* - page title; - 'previous_links' *string* - the trail content from site title until current page (both ends exclusive) - 'prolog' *string* - HTML code to prefix the navtrail item with - 'epilog' *string* - HTML code to suffix the navtrail item with - 'separator' *string* - HTML code that separates two navtrail items Output: - text containing the navtrail Note: returns empty string for Home page. (guessed by title). """ # load the right message language _ = gettext_set_language(ln) out = "" if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): # return empty string for the Home page return out else: out += create_html_link(CFG_SITE_URL, {'ln': ln}, _("Home"), {'class': 'navtrail'}) if previous_links: if out: out += separator out += previous_links if title: if out: out += separator if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): # hide site name, print Home instead out += cgi.escape(_("Home")) else: out += cgi.escape(title) return cgi.escape(prolog) + out + cgi.escape(epilog)
def reset_password(email, ln=None): """Reset user password.""" from datetime import timedelta from invenio.config import CFG_SITE_SUPPORT_EMAIL, CFG_SITE_NAME, \ CFG_SITE_NAME_INTL, CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS # create the reset key if ln is None: ln = g.ln from invenio.modules.access.mailcookie import mail_cookie_create_pw_reset reset_key = mail_cookie_create_pw_reset(email, cookie_timeout=timedelta( days=CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS)) if reset_key is None: return False # reset key could not be created # load the email template import invenio.legacy.template websession_templates = invenio.legacy.template.load('websession') # finally send the email from invenio.ext.email import send_email from invenio.base.i18n import _ if not send_email(CFG_SITE_SUPPORT_EMAIL, email, "%s %s" % (_("Password reset request for"), CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)), websession_templates. tmpl_account_reset_password_email_body( email, reset_key, request.remote_addr, ln)): return False # mail could not be sent return True # password reset email send successfully
def format_element(bfo, var=''): ''' Print several server specific variables. @param var: the name of the desired variable. Can be one of: CFG_SITE_NAME, CFG_SITE_NAME_INTL, CFG_SITE_LANG, CFG_VERSION, CFG_SITE_ADMIN_EMAIL, CFG_SITE_SUPPORT_EMAIL, CFG_SITE_URL, searchurl, recurl CFG_SITE_NAME: the name of the server CFG_SITE_NAME_INTL: internationalized name CFG_SITE_LANG: the default language of the server CFG_VERSION: the software version CFG_SITE_ADMIN_EMAIL: the admin email CFG_SITE_SUPPORT_EMAIL: the support email CFG_SITE_URL: the base url for the server searchurl: the search url for the server recurl: the base url for the record ''' recID = bfo.recID if var == '': out = '' elif var in ['name', 'CFG_SITE_NAME']: out = CFG_SITE_NAME elif var in ['i18n_name', 'CFG_SITE_NAME_INTL']: out = CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME) elif var in ['lang', 'CFG_SITE_LANG']: out = CFG_SITE_LANG elif var == 'CFG_VERSION': out = 'Invenio v' + str(CFG_VERSION) elif var in ['email', 'admin_email', 'CFG_SITE_ADMIN_EMAIL']: out = CFG_SITE_ADMIN_EMAIL elif var in ['support_email', 'CFG_SITE_SUPPORT_EMAIL']: out = CFG_SITE_SUPPORT_EMAIL elif var in ['CFG_SITE_RECORD']: out = CFG_SITE_RECORD elif var in ['weburl', 'CFG_SITE_URL']: out = CFG_SITE_URL if not out.endswith('/'): out += '/' elif var in ['CFG_BASE_URL']: out = CFG_BASE_URL if not out.endswith('/'): out += '/' elif var == 'searchurl': out = CFG_BASE_URL + '/search' if not out.endswith('/'): out += '/' elif var == 'absolutesearchurl': out = CFG_SITE_URL + '/search' if not out.endswith('/'): out += '/' elif var == 'recurl': out = CFG_BASE_URL if not out.endswith('/'): out += '/' out += CFG_SITE_RECORD + '/' + str(recID) elif var == 'absoluterecurl': out = CFG_SITE_URL if not out.endswith('/'): out += '/' out += CFG_SITE_RECORD + '/' + str(recID) else: out = 'Unknown variable: %s' % (var) return out
def format_element(bfo): """ Display administration links for this articles when user is an editor of the journal """ out = '' if bfo.user_info['uri'].startswith('/journal'): # Print editing links args = parse_url_string(bfo.user_info['uri']) journal_name = args["journal_name"] editor = False if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal', name="%s" % journal_name)[0] == 0: editor = True issue_number = args["issue"] if editor: recid = bfo.control_field('001') (doctype, identifier_element, identifier_field) = \ get_journal_submission_params(journal_name) if identifier_field.startswith('00'): identifier = bfo.control_field(identifier_field) else: identifier = bfo.field(identifier_field) out += ''' <div style="float:right;margin-left:5px;font-weight:700;"> <p> <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&sub=MBI%(doctype)s" target="_blank"> >> edit article</a> </p> <p> <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a> </p> <p> <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&issue=%(issue_number)s"> >> publish changes</a> </p> </div>''' % { 'CFG_SITE_URL': CFG_SITE_URL, 'CFG_SITE_RECORD': CFG_SITE_RECORD, 'identifier': identifier, 'recid': recid, 'journal_name': journal_name, 'issue_number': issue_number, 'doctype': doctype, 'identifier_element': identifier_element, 'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME) } return out
def edit(self, req, form): args = wash_urlargd(form, {"verbose" : (int, 0)}) uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(args['ln']) if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return webuser.page_not_authorized(req, "../youraccount/edit", navmenuid='youraccount') if webuser.isGuestUser(uid): return webuser.page_not_authorized(req, "../youraccount/edit", text=_("This functionality is forbidden to guest users."), navmenuid='youraccount') body = '' user_info = webuser.collect_user_info(req) if args['verbose'] == 9: keys = user_info.keys() keys.sort() for key in keys: body += "<b>%s</b>:%s<br />" % (key, user_info[key]) # set CSRF token: csrf_token, dummy_csrf_token_time = webuser.regenerate_csrf_token_if_needed(req) #check if the user should see bibcatalog user name / passwd in the settings can_config_bibcatalog = (acc_authorize_action(user_info, 'runbibedit')[0] == 0) can_config_profiling = (acc_authorize_action(user_info, 'profiling')[0] == 0) return page(title= _("Your Settings"), body=body+webaccount.perform_set(webuser.get_email(uid), args['ln'], can_config_bibcatalog, can_config_profiling, verbose=args['verbose'], csrf_token=csrf_token), navtrail="""<a class="navtrail" href="%s/youraccount/display?ln=%s">""" % (CFG_SITE_SECURE_URL, args['ln']) + _("Your Account") + """</a>""", description=_("%(x_name)s Personalize, Your Settings", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount')
def index(self, req, form): """Index page.""" argd = wash_urlargd(form, {'page': (int, 1), 'format': (str, "rc"), 'order_by': (str, "lcf"), 'per_page': (str, "all"), }) # TODO: support also "reviews", by adding new option to show/hide them if needed uid = getUid(req) # load the right language _ = gettext_set_language(argd['ln']) # Is site ready to accept comments? if not CFG_WEBCOMMENT_ALLOW_COMMENTS or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/yourcomments" % \ (CFG_SITE_SECURE_URL,), text="Comments are currently disabled on this site", navmenuid="yourcomments") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/yourcomments%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) user_info = collect_user_info(req) if not user_info['precached_sendcomments']: # Maybe we should still authorize if user submitted # comments in the past? return page_not_authorized(req, "../", \ text = _("You are not authorized to use comments.")) return page(title=_("Your Comments"), body=perform_display_your_comments(user_info, page_number=argd['page'], selected_order_by_option=argd['order_by'], selected_display_number_option=argd['per_page'], selected_display_format_option=argd['format'], ln=argd['ln']), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%(x_name)s View your previously submitted comments", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts', secure_page_p=1)
def tmpl_navtrailbox_body(self, ln, title, previous_links, separator, prolog, epilog): """Bootstrap friendly-Create navigation trail box body Parameters: - 'ln' *string* - The language to display - 'title' *string* - page title; - 'previous_links' *string* - the trail content from site title until current page (both ends exclusive) - 'prolog' *string* - HTML code to prefix the navtrail item with - 'epilog' *string* - HTML code to suffix the navtrail item with - 'separator' *string* - HTML code that separates two navtrail items Output: - text containing the navtrail Note: returns empty string for Home page. (guessed by title). """ # load the right message language _ = gettext_set_language(ln) if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): return "" # Breadcrumbs # breadcrumb objects should provide properties 'text' and 'url' # First element breadcrumbs = [ dict(text=_("Home"), url=CFG_SITE_URL), ] # Decode previous elements if previous_links: soup = BeautifulSoup(previous_links) for link in soup.find_all('a'): breadcrumbs.append( dict(text=unicode(' '.join(link.contents)), url=link.get('href'))) # Add head if title: breadcrumbs.append(dict(text=title, url='#')) return render_template_to_string( "breadcrumbs.html", breadcrumbs=breadcrumbs).encode('utf8')
def error_page(title, req, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title=_("Error"), body=create_error_box(req, title=str(title), verbose=0, ln=ln), description="%s - Internal Error" % site_name, keywords="%s, Internal Error" % site_name, uid=current_user.get_id(req), language=ln, req=req)
def delete(self, req, form): args = wash_urlargd(form, {}) uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(args['ln']) if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return webuser.page_not_authorized(req, "../youraccount/delete", navmenuid='youraccount') return page(title=_("Delete Account"), body=webaccount.perform_delete(args['ln']), navtrail="""<a class="navtrail" href="%s/youraccount/display?ln=%s">""" % (CFG_SITE_SECURE_URL, args['ln']) + _("Your Account") + """</a>""", description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount')
def warning_page(title, req, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title=_("Warning"), body=title, description="%s - Internal Error" % site_name, keywords="%s, Internal Error" % site_name, uid=current_user.get_id(req), language=ln, req=req)
def warning_page(title, req, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title = _("Warning"), body = title, description="%s - Internal Error" % site_name, keywords="%s, Internal Error" % site_name, uid = getUid(req), language=ln, req=req)
def error_page(title, req, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) site_name = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title = _("Error"), body = create_error_box(req, title=str(title), verbose=0, ln=ln), description="%s - Internal Error" % site_name, keywords="%s, Internal Error" % site_name, uid = getUid(req), language=ln, req=req)
def tmpl_navtrailbox_body(self, ln, title, previous_links, separator, prolog, epilog): """Bootstrap friendly-Create navigation trail box body Parameters: - 'ln' *string* - The language to display - 'title' *string* - page title; - 'previous_links' *string* - the trail content from site title until current page (both ends exclusive) - 'prolog' *string* - HTML code to prefix the navtrail item with - 'epilog' *string* - HTML code to suffix the navtrail item with - 'separator' *string* - HTML code that separates two navtrail items Output: - text containing the navtrail Note: returns empty string for Home page. (guessed by title). """ # load the right message language _ = gettext_set_language(ln) if title == CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME): return "" # Breadcrumbs # breadcrumb objects should provide properties 'text' and 'url' # First element breadcrumbs = [dict(text=_("Home"), url=CFG_SITE_URL), ] # Decode previous elements if previous_links: soup = BeautifulSoup(previous_links) for link in soup.find_all('a'): breadcrumbs.append(dict( text=unicode(' '.join(link.contents)), url=link.get('href'))) # Add head if title: breadcrumbs.append(dict(text=title, url='#')) return render_template_to_string("breadcrumbs.html", breadcrumbs=breadcrumbs).encode('utf8')
def warningMsg(title, req, c=None, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) if c is None: c = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title = _("Warning"), body = title, description="%s - Internal Error" % c, keywords="%s, Internal Error" % c, uid = getUid(req), language=ln, req=req, navmenuid='submit')
def warningMsg(title, req, c=None, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) if c is None: c = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page(title=_("Warning"), body=title, description="%s - Internal Error" % c, keywords="%s, Internal Error" % c, uid=getUid(req), language=ln, req=req, navmenuid='submit')
def format_element(bfo): """ Display administration links for this articles when user is an editor of the journal """ out = '' if bfo.user_info['uri'].startswith('/journal'): # Print editing links args = parse_url_string(bfo.user_info['uri']) journal_name = args["journal_name"] editor = False if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal', name="%s" % journal_name)[0] == 0: editor = True issue_number = args["issue"] if editor: recid = bfo.control_field('001') (doctype, identifier_element, identifier_field) = \ get_journal_submission_params(journal_name) if identifier_field.startswith('00'): identifier = bfo.control_field(identifier_field) else: identifier = bfo.field(identifier_field) out += ''' <div style="float:right;margin-left:5px;font-weight:700;"> <p> <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&sub=MBI%(doctype)s" target="_blank"> >> edit article</a> </p> <p> <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a> </p> <p> <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&issue=%(issue_number)s"> >> publish changes</a> </p> </div>''' % {'CFG_SITE_URL': CFG_SITE_URL, 'CFG_SITE_RECORD': CFG_SITE_RECORD, 'identifier': identifier, 'recid': recid, 'journal_name': journal_name, 'issue_number': issue_number, 'doctype': doctype, 'identifier_element': identifier_element, 'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME)} return out
def errorMsg(title, req, c=None, ln=CFG_SITE_LANG): # load the right message language _ = gettext_set_language(ln) if c is None: c = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) return page( title=_("Error"), body=create_error_box(req, title=str(title), verbose=0, ln=ln), description="%s - Internal Error" % c, keywords="%s, Internal Error" % c, uid=getUid(req), language=ln, req=req, navmenuid="submit", )
def format(bfo): """ Display administration links for this articles when user is an editor of the journal """ out = "" if bfo.user_info["uri"].startswith("/journal"): # Print editing links args = parse_url_string(bfo.user_info["uri"]) journal_name = args["journal_name"] editor = False if acc_authorize_action(bfo.user_info["uid"], "cfgwebjournal", name="%s" % journal_name)[0] == 0: editor = True issue_number = args["issue"] if editor: recid = bfo.control_field("001") (doctype, identifier_element, identifier_field) = get_journal_submission_params(journal_name) if identifier_field.startswith("00"): identifier = bfo.control_field(identifier_field) else: identifier = bfo.field(identifier_field) out += """ <div style="float:right;margin-left:5px;font-weight:700;"> <p> <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&sub=MBI%(doctype)s" target="_blank"> >> edit article</a> </p> <p> <a href="%(CFG_SITE_URL)s/record/%(recid)s" target="_blank"> >> record in %(CFG_SITE_NAME_INTL)s</a> </p> <p> <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&issue=%(issue_number)s"> >> publish changes</a> </p> </div>""" % { "CFG_SITE_URL": CFG_SITE_URL, "identifier": identifier, "recid": recid, "journal_name": journal_name, "issue_number": issue_number, "doctype": doctype, "identifier_element": identifier_element, "CFG_SITE_NAME_INTL": CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME), } return out
def email_html_footer(ln=CFG_SITE_LANG): """The html footer of the email @param ln: language @return: footer as a string""" ln = wash_language(ln) _ = gettext_set_language(ln) #standard footer out = """<br /><br /><em>%(best_regards)s</em> <hr /> <a href="%(siteurl)s"><strong>%(sitename)s</strong></a><br /> %(need_intervention_please_contact)s <a href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> """ % { 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'best_regards': _("Best regards"), 'siteurl': CFG_SITE_URL, 'need_intervention_please_contact': _("Need human intervention? Contact"), 'sitesupportemail': CFG_SITE_SUPPORT_EMAIL } return out
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL+"/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the title of the HTML page, not yet escaped for HTML - 'description' *string* - description goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) uri = req.unparsed_uri headerLinkbackTrackbackLink = '' if CFG_WEBLINKBACK_TRACKBACK_ENABLED: from invenio.weblinkback_templates import get_trackback_auto_discovery_tag # Embed a link in the header to subscribe trackbacks # TODO: This hack must be replaced with the introduction of the new web framework recordIndexInURI = uri.find('/' + CFG_SITE_RECORD + '/') # substring found --> offer trackback link in header if recordIndexInURI != -1: recid = uri[recordIndexInURI:len(uri)].split('/')[2].split("?")[0] #recid might end with ? for journal records headerLinkbackTrackbackLink = get_trackback_auto_discovery_tag(recid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" sitename = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) if headertitle == sitename: pageheadertitle = headertitle else: pageheadertitle = headertitle + ' - ' + sitename out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s" xmlns:og="http://opengraphprotocol.org/schema/" > <head> <title>%(pageheadertitle)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="%(cssurl)s/img/invenio%(cssskin)s-ie7.css" /> <![endif]--> <!--[if gt IE 8]> <style type="text/css">div.restrictedflag {filter:none;}</style> <![endif]--> %(canonical_and_alternate_urls)s <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> %(linkbackTrackbackLink)s <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"%(rtl_direction)s> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <div class="headerlogo"> <table class="headerbox" cellspacing="0"> <tr> <td align="right" valign="top" colspan="12"> <div class="userinfoboxbody"> %(userinfobox)s </div> <div class="headerboxbodylogo"> <a href="%(siteurl)s?ln=%(ln)s">%(sitename)s</a> </div> </td> </tr> <tr class="menu"> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(search_selected)s"> <a class="header%(search_selected)s" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(submit_selected)s"> <a class="header%(submit_selected)s" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(personalize_selected)s"> %(useractivities)s </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(help_selected)s"> <a class="header%(help_selected)s" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> </td> %(adminactivities)s <td class="headermoduleboxbodyblanklast"> </td> </tr> </table> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'rtl_direction': is_language_rtl(ln) and ' dir="rtl"' or '', 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'canonical_and_alternate_urls' : self.tmpl_canonical_and_alternate_urls(uri), 'cssurl' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'pageheadertitle': cgi.escape(pageheadertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description, True), 'keywords' : cgi.escape(keywords, True), 'metaheaderadd' : metaheaderadd, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_search' : _("Search"), 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'linkbackTrackbackLink': headerLinkbackTrackbackLink, 'inspect_templates_message' : inspect_templates_message } return out
def tmpl_pageheader( self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL + "/rss", body_css_classes=None, ): from invenio.weblinkback_templates import get_trackback_auto_discovery_tag # Embed a link in the header to subscribe trackbacks # TODO: This hack must be replaced with the introduction of the new web framework uri = req.unparsed_uri recordIndexInURI = uri.find("/" + CFG_SITE_RECORD + "/") headerLinkbackTrackbackLink = "" # substring found --> offer trackback link in header if recordIndexInURI != -1: recid = ( uri[recordIndexInURI : len(uri)].split("/")[2].split("?")[0] ) # recid might end with ? for journal records headerLinkbackTrackbackLink = get_trackback_auto_discovery_tag(recid) """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the title of the HTML page, not yet escaped for HTML - 'description' *string* - description goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = """ <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> """ else: inspect_templates_message = "" sitename = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) if headertitle == sitename: pageheadertitle = headertitle else: pageheadertitle = headertitle + " - " + sitename out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s" xmlns:og="http://opengraphprotocol.org/schema/" > <head> <title>%(pageheadertitle)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="%(cssurl)s/img/invenio%(cssskin)s-ie7.css" /> <![endif]--> <!--[if gt IE 8]> <style type="text/css">div.restrictedflag {filter:none;}</style> <![endif]--> <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> %(linkbackTrackbackLink)s <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"%(rtl_direction)s> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <div class="headerlogo"> <table class="headerbox" cellspacing="0"> <tr> <td align="right" valign="top" colspan="12"> <div class="userinfoboxbody"> %(userinfobox)s </div> <div class="headerboxbodylogo"> <a href="%(siteurl)s?ln=%(ln)s">%(sitename)s</a> </div> </td> </tr> <tr class="menu"> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(search_selected)s"> <a class="header%(search_selected)s" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(submit_selected)s"> <a class="header%(submit_selected)s" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(personalize_selected)s"> %(useractivities)s </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(help_selected)s"> <a class="header%(help_selected)s" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> </td> %(adminactivities)s <td class="headermoduleboxbodyblanklast"> </td> </tr> </table> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { "rtl_direction": is_language_rtl(ln) and ' dir="rtl"' or "", "siteurl": CFG_SITE_URL, "sitesecureurl": CFG_SITE_SECURE_URL, "cssurl": secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, "cssskin": CFG_WEBSTYLE_TEMPLATE_SKIN != "default" and "_" + CFG_WEBSTYLE_TEMPLATE_SKIN or "", "rssurl": rssurl, "ln": ln, "ln_iso_639_a": ln.split("_", 1)[0], "langlink": "?ln=" + ln, "sitename": CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), "pageheadertitle": cgi.escape(pageheadertitle), "sitesupportemail": CFG_SITE_SUPPORT_EMAIL, "description": cgi.escape(description, True), "keywords": cgi.escape(keywords, True), "metaheaderadd": metaheaderadd, "userinfobox": userinfobox, "navtrailbox": navtrailbox, "useractivities": useractivities_menu, "adminactivities": adminactivities_menu and ( '<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % { "personalize_selected": navmenuid.startswith("admin") and "selected" or "", "adminactivities": adminactivities_menu, } ) or '<td class="headermoduleboxbodyblank"> </td>', "pageheaderadd": pageheaderadd, "body_css_classes": body_css_classes and ' class="%s"' % " ".join(body_css_classes) or "", "search_selected": navmenuid == "search" and "selected" or "", "submit_selected": navmenuid == "submit" and "selected" or "", "personalize_selected": navmenuid.startswith("your") and "selected" or "", "help_selected": navmenuid == "help" and "selected" or "", "msg_search": _("Search"), "msg_submit": _("Submit"), "msg_personalize": _("Personalize"), "msg_help": _("Help"), "languagebox": self.tmpl_language_selection_box(req, ln), "unAPIurl": cgi.escape("%s/unapi" % CFG_SITE_URL), "linkbackTrackbackLink": headerLinkbackTrackbackLink, "inspect_templates_message": inspect_templates_message, } return out
def registerUser(req, email, passw, nickname, register_without_nickname=False, login_method=None, ln=CFG_SITE_LANG): """Register user with the desired values of NICKNAME, EMAIL and PASSW. If REGISTER_WITHOUT_NICKNAME is set to True, then ignore desired NICKNAME and do not set any. This is suitable for external authentications so that people can login without having to register an internal account first. Return 0 if the registration is successful, 1 if email is not valid, 2 if nickname is not valid, 3 if email is already in the database, 4 if nickname is already in the database, 5 when users cannot register themselves because of the site policy, 6 when the site is having problem contacting the user. If login_method is None or is equal to the key corresponding to local authentication, then CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS is taken in account for deciding the behaviour about registering. """ # is email valid? email = email.lower() if not email_valid_p(email): return 1 _ = gettext_set_language(ln) # is email already taken? res = run_sql("SELECT email FROM user WHERE email=%s", (email,)) if len(res) > 0: return 3 if register_without_nickname: # ignore desired nick and use default empty string one: nickname = "" else: # is nickname valid? if not nickname_valid_p(nickname): return 2 # is nickname already taken? res = run_sql("SELECT nickname FROM user WHERE nickname=%s", (nickname,)) if len(res) > 0: return 4 activated = 1 # By default activated if not login_method or not CFG_EXTERNAL_AUTHENTICATION[login_method]: # local login if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2: return 5 elif CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: activated = 2 # Email confirmation required elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1: activated = 0 # Administrator confirmation required if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: address_activation_key = mail_cookie_create_mail_activation(email) ip_address = req.remote_host or req.remote_ip try: if not send_email(CFG_SITE_SUPPORT_EMAIL, email, _("Account registration at %s") % CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), tmpl.tmpl_account_address_activation_email_body(email, address_activation_key, ip_address, ln)): return 1 except (smtplib.SMTPException, socket.error): return 6 # okay, go on and register the user: user_preference = get_default_user_preferences() uid = run_sql("INSERT INTO user (nickname, email, password, note, settings, last_login) " "VALUES (%s,%s,AES_ENCRYPT(email,%s),%s,%s, NOW())", (nickname, email, passw, activated, serialize_via_marshal(user_preference))) if activated == 1: # Ok we consider the user as logged in :-) setUid(req, uid) return 0
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_BASE_URL+"/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the title of the HTML page, not yet escaped for HTML - 'description' *string* - description goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page, not yet escaped for HTML - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # Including HEPData headers ( Ugly hack but no obvious way to avoid this ...) if CFG_INSPIRE_SITE: hepDataAdditions = """<script type="text/javascript" src="%s/js/hepdata.js"></script>""" \ % (CFG_BASE_URL, ) hepDataAdditions += """<link rel="stylesheet" href="%s/img/hepdata.css" type="text/css" />""" \ % (CFG_BASE_URL, ) else: hepDataAdditions = "" # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) uri = req.unparsed_uri headerLinkbackTrackbackLink = '' if CFG_WEBLINKBACK_TRACKBACK_ENABLED: from invenio.weblinkback_templates import get_trackback_auto_discovery_tag # Embed a link in the header to subscribe trackbacks # TODO: This hack must be replaced with the introduction of the new web framework recordIndexInURI = uri.find('/' + CFG_SITE_RECORD + '/') # substring found --> offer trackback link in header if recordIndexInURI != -1: recid = uri[recordIndexInURI:len(uri)].split('/')[2].split("?")[0] #recid might end with ? for journal records headerLinkbackTrackbackLink = get_trackback_auto_discovery_tag(recid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" sitename = CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME) if headertitle == sitename: pageheadertitle = headertitle else: pageheadertitle = headertitle + ' - ' + sitename metabase = "" stripped_url = CFG_SITE_URL.replace("://", "") if not CFG_BASE_URL and '/' in stripped_url: metabase = "<base href='%s'>" % (CFG_SITE_URL,) out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s" xmlns:og="http://opengraphprotocol.org/schema/" > <head> <title>%(pageheadertitle)s</title> %(metabase)s <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="%(cssurl)s/img/invenio%(cssskin)s-ie7.css" /> <![endif]--> <!--[if gt IE 8]> <style type="text/css">div.restrictedflag {filter:none;}</style> <![endif]--> %(canonical_and_alternate_urls)s <!-- <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> --> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <link rel="icon" href="/img/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon"> %(linkbackTrackbackLink)s <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <meta name="google-site-verification" content="mLqufkdPNxUHXFW4obCfN5NJXr4sD_SlnvsOla7RZAE" /> <meta name="msvalidate.01" content="EA9805F0F62E4FF22B98853713964B28" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> %(hepDataAdditions)s %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"%(rtl_direction)s> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <div class="headerlogo"> <table class="headerbox" cellspacing="0"> <tr> <td align="right" valign="top" colspan="12"> <div class="headerboxbodylogo"> <a href="%(cssurl)s/?ln=%(ln)s">SCOAP<sup>3</sup> Repository (βeta)</a> </div> </td> </tr> <tr style="background-color: #679A70;"> <td style="padding: 10px; font-size: medium; color: #FFF;"><a href="/" style="text-decoration: none; color: #FFF;">HOME</a> :: <a href="http://scoap3.org/" style="text-decoration: none; color: #FFF;">SCOAP<sup>3</sup></a> :: <a href="http://scoap3.org/scoap3-repository-help" style="text-decoration: none; color: #FFF;">HELP</a> :: <a href="http://scoap3.org/scoap3-repository" style="text-decoration: none; color: #FFF;">ABOUT</a></td> </tr> <!-- <tr class="menu"> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(search_selected)s"> <a class="header%(search_selected)s" href="%(cssurl)s/?ln=%(ln)s">%(msg_search)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(submit_selected)s"> <a class="header%(submit_selected)s" href="%(cssurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(personalize_selected)s"> %(useractivities)s </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(help_selected)s"> <a class="header%(help_selected)s" href="%(cssurl)s/help/%(langlink)s">%(msg_help)s</a> </td> %(adminactivities)s <td class="headermoduleboxbodyblanklast"> </td> </tr>--> </table> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'metabase': metabase, 'rtl_direction': is_language_rtl(ln) and ' dir="rtl"' or '', 'siteurl': CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'canonical_and_alternate_urls' : self.tmpl_canonical_and_alternate_urls(uri), 'cssurl' : CFG_BASE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'pageheadertitle': cgi.escape(pageheadertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description, True), 'keywords' : cgi.escape(keywords, True), 'metaheaderadd' : metaheaderadd, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_search' : _("Search"), 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'linkbackTrackbackLink': headerLinkbackTrackbackLink, 'hepDataAdditions': hepDataAdditions, 'inspect_templates_message' : inspect_templates_message } return out
def remove(self, req, form): argd = wash_urlargd(form, { 'name': (str, None), 'idq': (int, None), 'idb': (int, None), }) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/remove" % \ (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url( req, "%s/youraccount/login%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( { 'referer': "%s/youralerts/remove%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( argd, {})), "ln": argd['ln'] }, {}))) # load the right language _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) try: html = webalert.perform_remove_alert(argd['name'], argd['idq'], argd['idb'], uid, ln=argd['ln']) except webalert.AlertError, msg: return page( title=_("Error"), body=webalert_templates.tmpl_errorMsg(ln=argd['ln'], error_msg=msg), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account': _("Your Account"), }, description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts')
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL+"/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the second part of the page HTML title - 'description' *string* - description goes to the metadata in the header of the HTML page - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s"> <head> <title>%(headertitle)s - %(sitename)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s" onload="document.search.p.focus()"> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <table class="headerbox" cellspacing="0"> <tr> <td align="left"> <div> <a class="img" href="%(siteurl)s?ln=%(ln)s"> <img border="0" src="%(cssurl)s/img/inspire_logo_beta.png" alt="INSPIRE" /> </a> </div> </td> <td class="feedbackbox"> <div class="feedbackboxbody"> Welcome to <a href="http://www.projecthepinspire.net">INSPIRE</a> β: the upgrade of SPIRES<br /> We now recommend that you use this site instead of SPIRES<br /> %(feedback)s </div> </td> </tr> </table> <div class="navbar"> <a id="nav-hep" href="%(siteurl)s?ln=%(ln)s">Hep</a> :: <a id="nav-help" href="%(siteurl)s/help/?ln=%(ln)s">%(msg_help)s</a> ..::.. <strong>SPIRES</strong> <a id="nav-hepnames" href="http://www.slac.stanford.edu/spires/hepnames/">HepNames</a> :: <a id="nav-inst" href="http://www.slac.stanford.edu/spires/institutions/">Inst</a> :: <a id="nav-conf" href="http://www.slac.stanford.edu/spires/conferences/">Conf</a> :: <a id="nav-exp" href="http://www.slac.stanford.edu/spires/experiments/">Exp</a> :: <a id="nav-jobs" href="http://www.slac.stanford.edu/spires/jobs/">Jobs</a> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'cssurl' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'headertitle' : cgi.escape(headertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description), 'keywords' : cgi.escape(keywords), 'metaheaderadd' : metaheaderadd, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_search' : _("Search"), 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'languagebox' : self.tmpl_language_selection_box(req, ln), 'feedback' : self.tmpl_feedback_box(ln), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'inspect_templates_message' : inspect_templates_message } return out
def registerUser(req, email, passw, nickname, register_without_nickname=False, login_method=None, ln=CFG_SITE_LANG): """Register user with the desired values of NICKNAME, EMAIL and PASSW. If REGISTER_WITHOUT_NICKNAME is set to True, then ignore desired NICKNAME and do not set any. This is suitable for external authentications so that people can login without having to register an internal account first. Return 0 if the registration is successful, 1 if email is not valid, 2 if nickname is not valid, 3 if email is already in the database, 4 if nickname is already in the database, 5 when users cannot register themselves because of the site policy, 6 when the site is having problem contacting the user. If login_method is None or is equal to the key corresponding to local authentication, then CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS is taken in account for deciding the behaviour about registering. """ # is email valid? email = email.lower() if not email_valid_p(email): return 1 _ = gettext_set_language(ln) # is email already taken? res = run_sql("SELECT email FROM user WHERE email=%s", (email,)) if len(res) > 0: return 3 if register_without_nickname: # ignore desired nick and use default empty string one: nickname = "" else: # is nickname valid? if not nickname_valid_p(nickname): return 2 # is nickname already taken? res = run_sql("SELECT nickname FROM user WHERE nickname=%s", (nickname,)) if len(res) > 0: return 4 activated = 1 # By default activated if not login_method or not CFG_EXTERNAL_AUTHENTICATION[login_method]: # local login if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2: return 5 elif CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: activated = 2 # Email confirmation required elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1: activated = 0 # Administrator confirmation required if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: address_activation_key = mail_cookie_create_mail_activation( email, cookie_timeout=datetime.timedelta( days=CFG_WEBSESSION_ADDRESS_ACTIVATION_EXPIRE_IN_DAYS ) ) try: ip_address = req.remote_host or req.remote_ip except: ip_address = None try: if not send_email(CFG_SITE_SUPPORT_EMAIL, email, _("Account registration at %(sitename)s", sitename=CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME)), tmpl.tmpl_account_address_activation_email_body( email, address_activation_key, ip_address, ln)): return 1 except (smtplib.SMTPException, socket.error): return 6 # okay, go on and register the user: FIXME user = User(nickname=nickname, email=email, password=passw, note=activated) try: db.session.add(user) db.session.commit() except: db.session.rollback() return 7 if activated == 1: # Ok we consider the user as logged in :-) setUid(req, uid) return 0
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_BASE_URL + "/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the second part of the page HTML title - 'description' *string* - description goes to the metadata in the header of the HTML page - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ hepDataAdditions = """<script type="text/javascript" src="%s/js/hepdata.js"></script>""" \ % (CFG_BASE_URL, ) hepDataAdditions += """<link rel="stylesheet" href="%s/img/hepdata.css" type="text/css" />""" \ % (CFG_BASE_URL, ) # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) uri = req.unparsed_uri cssskin = CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" #FIXME: Hack to include datepicker for submissions using WebSubmit submission_js = "" if navmenuid == "submit": # src taken from batchuploader form submission_js = """ <script type="text/javascript" src="%(site_url)s/js/jquery-ui.min.js"></script> <link type="text/css" href="%(site_url)s/img/jquery-ui.css" rel="stylesheet" /> <link type="text/css" href="%(site_url)s/img/jobsubmit.css" rel="stylesheet" /> <script type="text/javascript"> //<![CDATA[ function clearText(field){ if (field.value == field.defaultValue){ field.value = ''; } } function defText(field){ if (field.value == ''){ field.value = field.defaultValue; } } $(function() { $(".datepicker").datepicker({dateFormat: 'yy-mm-dd'}); $('.datepicker[name="CONFSUBMIT_SDAT"]').datepicker("destroy"); $('.datepicker[name="CONFSUBMIT_SDAT"]').datepicker({ dateFormat: 'yy-mm-dd', altField: '.datepicker[name="CONFSUBMIT_FDAT"]' }); }); function split(val) { return val.split( /;\s*/ ); } function extractLast( term ) { return split( term ).pop(); } function autocomplete_kb(that, kb_name) { $.getJSON("/kb/export", {kbname: kb_name, format: 'jquery'}) .done(function(json) { that.autocomplete({ minLength: 2, source: function (request, response) { // delegate back to autocomplete, but extract the last term response($.ui.autocomplete.filter(json, extractLast(request.term))); }, focus: function() { // prevent value inserted on focus return false; }, select: function(event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push( ui.item.value ); // add placeholder to get the semicolon-and-space at the end terms.push(""); this.value = terms.join("; "); return false; } }); }) } $(function () { $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'}); autocomplete_kb($("#jobsubmitAffil"), "InstitutionsCollection"); autocomplete_kb($("#jobsubmitExp"), "ExperimentsCollection"); }) //]]> </script> """ % { 'site_url': CFG_BASE_URL } # Hack to add jobs filter JS to Jobs collection pages if "Jobs" in body_css_classes: metaheaderadd += '<script type="text/javascript" src="%s/js/jobs_filter.js"></script>' % \ (CFG_BASE_URL,) out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s"> <head> <title>%(headertitle)s - INSPIRE-HEP</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(inspire_css)s" type="text/css" /> %(canonical_and_alternate_urls)s <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <meta name="msvalidate.01" content="EA9805F0F62E4FF22B98853713964B28" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { if ((document.search) && ('baseURI' in document) && (document.baseURI.indexOf('/search?') == -1)) { $('#mainlightsearchfield').focus(); } }); //]]> </script> %(submissionjs)s %(metaheaderadd)s %(hepDataAdditions)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <table class="headerbox" cellspacing="0"> <tr> <td align="left"> <div> <a class="img" href="%(siteurl)s/?ln=%(ln)s"> <img border="0" src="%(cssurl)s/img/inspire_logo_hep.png" alt="INSPIRE" /> </a> </div> </td> <td class="feedbackbox"> <div class="feedbackboxbody"> Welcome to <a href="http://www.projecthepinspire.net">INSPIRE</a>, the High Energy Physics information system. Please direct questions, comments or concerns to <a href="mailto:[email protected]">[email protected]</a>. </div> </td> </tr> </table> <div class="navbar"> <a id="nav-hep" href="%(siteurl)s/?ln=%(ln)s">Hep</a> :: <a id="nav-hepnames" href="%(siteurl)s/collection/HepNames">HepNames</a> :: <a id="nav-inst" href="%(siteurl)s/collection/Institutions">Institutions</a> :: <a id="nav-conf" href="%(siteurl)s/collection/Conferences">Conferences</a> :: <a id="nav-jobs" href="%(siteurl)s/collection/Jobs">Jobs</a> :: <a id="nav-exp" href="%(siteurl)s/collection/Experiments">Experiments</a> :: <a id="nav-journals" href="%(siteurl)s/collection/Journals">Journals</a> :: <a id="nav-help" href="%(siteurl)s/help/?ln=%(ln)s">%(msg_help)s</a> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'siteurl' : CFG_BASE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'cssurl' : CFG_BASE_URL, 'canonical_and_alternate_urls' : self.tmpl_canonical_and_alternate_urls(uri), 'inspire_css' : "%s/" % CFG_BASE_URL + auto_version_url("img/" + 'invenio%s.css' % cssskin), 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'headertitle' : cgi.escape(headertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description), 'keywords' : cgi.escape(keywords), 'metaheaderadd' : metaheaderadd, 'submissionjs' : submission_js, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'languagebox' : self.tmpl_language_selection_box(req, ln), 'feedback' : self.tmpl_feedback_box(ln), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_BASE_URL), 'inspect_templates_message' : inspect_templates_message, 'hepDataAdditions' : hepDataAdditions } return out
def remove(self, req, form): argd = wash_urlargd(form, {'name': (str, None), 'idq': (int, None), 'idb': (int, None), }) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/remove" % \ (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url(req, "%s/youraccount/login%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd({ 'referer' : "%s/youralerts/remove%s" % ( CFG_SITE_SECURE_URL, make_canonical_urlargd(argd, {})), "ln" : argd['ln']}, {}))) # load the right language _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) try: html = webalert.perform_remove_alert(argd['name'], argd['idq'], argd['idb'], uid, ln=argd['ln']) except webalert.AlertError as msg: return page(title=_("Error"), body=webalert_templates.tmpl_errorMsg(ln=argd['ln'], error_msg=msg), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%(x_name)s Personalize, Set a new alert", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts') # register event in webstat alert_str = "%s (%d)" % (argd['name'], argd['idq']) if user_info['email']: user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["remove", alert_str, user_str]) except: register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'") # display success return page(title=_("Display alerts"), body=html, navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%(x_name)s Personalize, Display alerts", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME)), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts')
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL+"/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the second part of the page HTML title - 'description' *string* - description goes to the metadata in the header of the HTML page - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" #FIXME: Hack to include datepicker for submissions using WebSubmit submission_js = "" if navmenuid == "submit": # src taken from batchuploader form submission_js = """ <script type="text/javascript" src="%(site_url)s/js/jquery-ui.min.js"></script> <link type="text/css" href="%(site_url)s/img/jquery-ui.css" rel="stylesheet" /> <style type="text/css"> div.ui-datepicker{ font-size:12px; } </style> <script type="text/javascript"> //<![CDATA[ function clearText(field){ if (field.value == field.defaultValue){ field.value = ''; } } function defText(field){ if (field.value == ''){ field.value = field.defaultValue; } } $(function() { $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'}); }); //]]> </script> """ % { 'site_url' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL } # Hack to add jobs filter JS to Jobs collection pages if "Jobs" in body_css_classes: metaheaderadd += '<script type="text/javascript" src="%s/js/jobs_filter.js"></script>' % \ (secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL,) out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s"> <head> <title>%(headertitle)s - INSPIRE-HEP</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function() { if ((document.search) && ('baseURI' in document) && (document.baseURI.indexOf('/search?') == -1)) { $('#mainlightsearchfield').focus(); } }); //]]> </script> %(submissionjs)s %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <table class="headerbox" cellspacing="0"> <tr> <td align="left"> <div> <a class="img" href="%(siteurl)s?ln=%(ln)s"> <img border="0" src="%(cssurl)s/img/inspire_logo_hep.png" alt="INSPIRE" /> </a> </div> </td> <td class="feedbackbox"> <div class="feedbackboxbody"> Welcome to <a href="http://www.projecthepinspire.net">INSPIRE</a>! INSPIRE is now in full operation and supersedes SPIRES. Please direct questions, comments or concerns to <a href="mailto:[email protected]">[email protected]</a>. </div> </td> </tr> </table> <div class="navbar"> <a id="nav-hep" href="%(siteurl)s?ln=%(ln)s">Hep</a> :: <a id="nav-hepnames" href="%(siteurl)s/collection/HepNames">HepNames</a> :: <a id="nav-inst" href="%(siteurl)s/collection/Institutions">Institutions</a> :: <a id="nav-conf" href="%(siteurl)s/collection/Conferences">Conferences</a> :: <a id="nav-jobs" href="%(siteurl)s/collection/Jobs">Jobs</a> :: <a id="nav-exp" href="%(siteurl)s/collection/Experiments">Experiments</a> :: <a id="nav-help" href="%(siteurl)s/help/?ln=%(ln)s">%(msg_help)s</a> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'cssurl' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'headertitle' : cgi.escape(headertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description), 'keywords' : cgi.escape(keywords), 'metaheaderadd' : metaheaderadd, 'submissionjs' : submission_js, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'languagebox' : self.tmpl_language_selection_box(req, ln), 'feedback' : self.tmpl_feedback_box(ln), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'inspect_templates_message' : inspect_templates_message } return out
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl='', body_css_classes=None): if secure_page_p: external_scripts = """ <link href="https://www.epfl.ch/css/epfl.css" media="all" rel="stylesheet" type="text/css" /> <link href="https://www.epfl.ch/css/applications.css" media="all" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="https://www.epfl.ch/js/jquery-epfl.min.js"></script> <script type="text/javascript" src="https://www.epfl.ch/js/globalnav.js"></script>""" else: # secure_page_p seems to be empty all the time... Therefore, we # return https all the time. external_scripts = """ <link href="https://www.epfl.ch/css/epfl.css" media="all" rel="stylesheet" type="text/css" /> <link href="https://www.epfl.ch/css/applications.css" media="all" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="https://www.epfl.ch/js/jquery-epfl.min.js"></script> <script type="text/javascript" src="https://www.epfl.ch/js/globalnav.js"></script>""" rss = '' if rssurl: rss = '<link rel="alternate" type="application/rss+xml" title="%s RSS" href="%s" />' % (CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), rssurl) out = """\ <!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln)s" xml:lang="%(ln)s"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>%(title)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> %(rss)s <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> %(external_scripts)s <link href="/media/css/invenio_epfl.css" media="all" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/media/js/invenio-epfl.js"></script> %(signature)s %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln)s"> %(header)s <div id="main-content"> %(breadcrumbs)s %(language)s <div class="clear"></div> <p class="h1"><a href="/?ln=%(ln)s">Infoscience</a><!-- Publications <acronym title="École Polytechnique Fédérale de Lausanne" class="local-color-text">EPFL</acronym>--></p> %(message)s %(navigation)s """ % {'signature': epfl_header_sig, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'ln' : ln, 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail': CFG_SITE_SUPPORT_EMAIL, 'siteurl': CFG_SITE_URL, 'rss': rss, 'unAPIurl': '%s/unapi' % CFG_SITE_URL, 'metaheaderadd': metaheaderadd, 'header': epfl_header_html_fr if ln == 'fr' else epfl_header_html_en, 'title': saxutils.unescape(headertitle), 'breadcrumbs': navtrailbox, 'language': self.tmpl_language_selection_box(req, ln), 'navigation': self.get_navigation(req, useractivities_menu, adminactivities_menu, navmenuid, ln), 'external_scripts': external_scripts, 'message': '' #self.maintenance_warning(ln), } return out
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL+"/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the second part of the page HTML title - 'description' *string* - description goes to the metadata in the header of the HTML page - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" #FIXME: Hack to include datepicker for submissions using WebSubmit submission_js = "" if navmenuid == "submit": # src taken from batchuploader form submission_js = """ <script type="text/javascript" src="%(site_url)s/js/ui.datepicker.min.js"></script> <link type="text/css" href="%(site_url)s/img/jquery-ui.css" rel="stylesheet" /> <style type="text/css"> div.ui-datepicker{ font-size:12px; } </style> <script type="text/javascript"> function clearText(field){ if (field.value == field.defaultValue){ field.value = ''; } } function defText(field){ if (field.value == ''){ field.value = field.defaultValue; } } $(function() { $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'}); }); </script> """ % { 'site_url' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL } # Hack to add jobs filter JS to Jobs collection pages if "Jobs" in body_css_classes: metaheaderadd += '<script type="text/javascript" src="%s/js/jobs_filter.js"></script>' % \ (secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL,) out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s"> <head> <title>%(headertitle)s - %(sitename)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> <script type="text/javascript" src="%(cssurl)s/js/jquery.min.js"></script> %(submissionjs)s %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s" onload="if ((document.search) && (document.baseURI.indexOf('/search?') == -1)) { document.search.p.focus(); }"> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <table class="headerbox" cellspacing="0"> <tr> <td align="left"> <div> <a class="img" href="%(siteurl)s?ln=%(ln)s"> <img border="0" src="%(cssurl)s/img/inspire_logo_hep.png" alt="INSPIRE" /> </a> </div> </td> <td class="feedbackbox"> <div class="feedbackboxbody"> Welcome to <a href="http://www.projecthepinspire.net">INSPIRE</a>! INSPIRE is out of beta and ready to replace SPIRES. SPIRES will be switched off soon. If you have questions, comments or concerns, please email us at <a href="mailto:[email protected]">[email protected]</a>. </div> </td> </tr> </table> <div class="navbar"> <a id="nav-hep" href="%(siteurl)s?ln=%(ln)s">Hep</a> :: <a id="nav-hepnames" href="%(siteurl)s/collection/HepNames">HepNames</a> :: <a id="nav-inst" href="%(siteurl)s/collection/Institutions">Institutions</a> :: <a id="nav-conf" href="%(siteurl)s/collection/Conferences">Conferences</a> :: <a id="nav-jobs" href="%(siteurl)s/collection/Jobs">Jobs</a> :: <a id="nav-help" href="%(siteurl)s/help/?ln=%(ln)s">%(msg_help)s</a> ..::.. <strong>SPIRES</strong> :: <a id="nav-exp" href="http://www.slac.stanford.edu/spires/experiments/">Exp</a> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'cssurl' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'headertitle' : cgi.escape(headertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description), 'keywords' : cgi.escape(keywords), 'metaheaderadd' : metaheaderadd, 'submissionjs' : submission_js, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'languagebox' : self.tmpl_language_selection_box(req, ln), 'feedback' : self.tmpl_feedback_box(ln), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'inspect_templates_message' : inspect_templates_message } return out
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != "$Date$": if lastupdated.startswith("$Date: ") or lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" out = """ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> :: <a class="footer" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(msg_personalize)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> <br /> %(msg_poweredby)s <a class="footer" href="http://invenio-software.org/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> %(languagebox)s </div> <!-- replaced page footer --> </div> </body> </html> """ % { "siteurl": CFG_SITE_URL, "sitesecureurl": CFG_SITE_SECURE_URL, "ln": ln, "langlink": "?ln=" + ln, "sitename": CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), "sitesupportemail": CFG_SITE_SUPPORT_EMAIL, "msg_search": _("Search"), "msg_submit": _("Submit"), "msg_personalize": _("Personalize"), "msg_help": _("Help"), "msg_poweredby": _("Powered by"), "msg_maintainedby": _("Maintained by"), "msg_lastupdated": msg_lastupdated, "languagebox": self.tmpl_language_selection_box(req, ln), "version": CFG_VERSION, "pagefooteradd": pagefooteradd, } return out
suffix= "Do the webstat tables exists? Try with 'webstatadmin --load-config'" ) return page( title=_("Modify alert settings"), body=html, navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account': _("Your Account"), }, description=_("%s Personalize, Modify alert settings") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts') def list(self, req, form): argd = wash_urlargd(form, {}) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1:
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ from invenio.search_engine import guess_primary_collection_of_a_record # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != '$Date$': if lastupdated.startswith("$Date: ") or \ lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(\ convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" # Prepare Piwik custom variables if we are in a detailed record page record_page_re = re.compile( "^/record/(?P<recid>[0-9]+)/?(?P<page_type>.*)") custom_variables = "" record_page_match = record_page_re.match(req.uri) if record_page_match: record_collection = guess_primary_collection_of_a_record( record_page_match.group('recid')) custom_variables = """ _paq.push(['setCustomVariable', 1, // Index, the number from 1 to 5 where this custom variable name is stored "Collection", // Name, the name of the variable "%(collection_name)s", // Value "page" // Scope of the custom variable ]); """ % { 'collection_name': record_collection } if record_page_match.group('page_type'): custom_variables += """ _paq.push(['setCustomVariable', 2, "Type", "%(page_type)s", "page" ]); _paq.push(['setCustomVariable', 3, "CollectionType", "%(page_collection_type)s", "page" ]); """ % { 'page_type': record_page_match.group('page_type'), 'page_collection_type': record_collection + record_page_match.group('page_type') } out = """ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> :: <a class="footer" href="%(siteurl)s/info/general/terms-of-use">%(msg_terms)s</a> :: <a class="footer" href="%(siteurl)s/info/general/privacy-policy">%(msg_privacy)s</a> <br /> %(msg_poweredby)s <a class="footer" href="http://invenio-software.org/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> %(languagebox)s </div> <!-- replaced page footer --> </div> <!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; (function(){ var u=(("https:" == document.location.protocol) ? "https://inspirehep.net/piwik/" : "http://inspirehep.net/piwik/"); _paq.push(['setSiteId', '8']); %(custom_variables)s _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })(); </script> <noscript><p><img src="http://inspirehep.net/piwik/piwik.php?idsite=8" style="border:0" alt="" /></p></noscript> <!-- End Piwik Code --> </body> </html> """ % { 'siteurl': CFG_BASE_URL, 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': ln, 'langlink': '?ln=' + ln, 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail': '*****@*****.**', 'msg_search': _("Search"), 'msg_help': _("Help"), 'msg_terms': _("Terms of use"), 'msg_privacy': _("Privacy policy"), 'msg_poweredby': _("Powered by"), 'msg_maintainedby': _("Problems/Questions to"), 'msg_lastupdated': msg_lastupdated, 'languagebox': self.tmpl_language_selection_box(req, ln), 'version': self.trim_version(CFG_VERSION), 'pagefooteradd': pagefooteradd, 'custom_variables': custom_variables } return out
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ from invenio.search_engine import guess_primary_collection_of_a_record # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != '$Date$': if lastupdated.startswith("$Date: ") or \ lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(\ convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" # Prepare Piwik custom variables if we are in a detailed record page custom_variables = "" record_collection = "" page_type = "" parsed_uri = urlparse(req.unparsed_uri) # HACK: I know it's horrible code. :-( record_page_match = re.match( "^/record/(?P<recid>[0-9]+)(/(?P<page_type>.+)?)?$", parsed_uri.path) if record_page_match: record_collection = guess_primary_collection_of_a_record( record_page_match.group('recid')) page_type = record_page_match.group('page_type') or 'detailed' if re.match("^/search/?$", parsed_uri.path): cc = parse_qs(parsed_uri.query).get('cc', [CFG_SITE_NAME]) record_collection = cc.pop() collection_page_match = re.match( "^/$|^/collection/(?P<collection>.+)/?$", parsed_uri.path) if collection_page_match: record_collection = collection_page_match.groupdict().get( 'collection', CFG_SITE_NAME) if record_collection: custom_variables = """\ _paq.push(['setCustomVariable', 1, // Index, the number from 1 to 5 where this custom variable name is stored "Collection", // Name, the name of the variable %(collection_name)s, // Value "page" // Scope of the custom variable ]); """ % { 'collection_name': js_escape(record_collection) } if page_type: custom_variables += """\ _paq.push(['setCustomVariable', 2, "Type", %(page_type)s, "page" ]); _paq.push(['setCustomVariable', 3, "CollectionType", %(page_collection_type)s, "page" ]); """ % { 'page_type': js_escape(page_type), 'page_collection_type': js_escape(record_collection + page_type) } out = """\ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> :: <a class="footer" href="%(siteurl)s/info/general/terms-of-use">%(msg_terms)s</a> :: <a class="footer" href="%(siteurl)s/info/general/privacy-policy">%(msg_privacy)s</a> <br /> %(msg_poweredby)s <a class="footer" href="http://invenio-software.org/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> %(languagebox)s </div> <!-- replaced page footer --> </div> """ % { 'siteurl': CFG_BASE_URL, 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': ln, 'langlink': '?ln=' + ln, 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail': '*****@*****.**', 'msg_search': _("Search"), 'msg_help': _("Help"), 'msg_terms': _("Terms of use"), 'msg_privacy': _("Privacy policy"), 'msg_poweredby': _("Powered by"), 'msg_maintainedby': _("Problems/Questions to"), 'msg_lastupdated': msg_lastupdated, 'languagebox': self.tmpl_language_selection_box(req, ln), 'version': self.trim_version(CFG_VERSION), 'pagefooteradd': pagefooteradd, } if not isUserAdmin(collect_user_info(req)): out += """\ <!-- Piwik --> <script type="text/javascript"> try { var _paq = _paq || []; _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//piwik.inspirehep.net/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', 8]); %(custom_variables)s var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })();} catch(err) { (function() { var img = document.createElement('img'); img.src = '//piwik.inspirehep.net/piwik.php?idsite=8&rec=1&bots=1'; document.body.appendChild(img); })(); } </script> <noscript><p><img src="//piwik.inspirehep.net/piwik.php?idsite=8&rec=1&bots=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code --> """ % { 'custom_variables': custom_variables } out += """\ </body> </html> """ return out
def tmpl_pageheader(self, req, ln=CFG_SITE_LANG, headertitle="", description="", keywords="", userinfobox="", useractivities_menu="", adminactivities_menu="", navtrailbox="", pageheaderadd="", uid=0, secure_page_p=0, navmenuid="admin", metaheaderadd="", rssurl=CFG_SITE_URL + "/rss", body_css_classes=None): """Creates a page header Parameters: - 'ln' *string* - The language to display - 'headertitle' *string* - the second part of the page HTML title - 'description' *string* - description goes to the metadata in the header of the HTML page - 'keywords' *string* - keywords goes to the metadata in the header of the HTML page - 'userinfobox' *string* - the HTML code for the user information box - 'useractivities_menu' *string* - the HTML code for the user activities menu - 'adminactivities_menu' *string* - the HTML code for the admin activities menu - 'navtrailbox' *string* - the HTML code for the navigation trail box - 'pageheaderadd' *string* - additional page header HTML code - 'uid' *int* - user ID - 'secure_page_p' *int* (0 or 1) - are we to use HTTPS friendly page elements or not? - 'navmenuid' *string* - the id of the navigation item to highlight for this page - 'metaheaderadd' *string* - list of further tags to add to the <HEAD></HEAD> part of the page - 'rssurl' *string* - the url of the RSS feed for this page - 'body_css_classes' *list* - list of classes to add to the body tag Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if body_css_classes is None: body_css_classes = [] body_css_classes.append(navmenuid) if CFG_WEBSTYLE_INSPECT_TEMPLATES: inspect_templates_message = ''' <table width="100%%" cellspacing="0" cellpadding="2" border="0"> <tr bgcolor="#aa0000"> <td width="100%%"> <font color="#ffffff"> <strong> <small> CFG_WEBSTYLE_INSPECT_TEMPLATES debugging mode is enabled. Please hover your mouse pointer over any region on the page to see which template function generated it. </small> </strong> </font> </td> </tr> </table> ''' else: inspect_templates_message = "" out = """\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="%(ln_iso_639_a)s" xml:lang="%(ln_iso_639_a)s"> <head> <title>%(headertitle)s - %(sitename)s</title> <link rev="made" href="mailto:%(sitesupportemail)s" /> <link rel="stylesheet" href="%(cssurl)s/img/invenio%(cssskin)s.css" type="text/css" /> <link rel="alternate" type="application/rss+xml" title="%(sitename)s RSS" href="%(rssurl)s" /> <link rel="search" type="application/opensearchdescription+xml" href="%(siteurl)s/opensearchdescription" title="%(sitename)s" /> <link rel="unapi-server" type="application/xml" title="unAPI" href="%(unAPIurl)s" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="%(ln)s" /> <meta name="description" content="%(description)s" /> <meta name="keywords" content="%(keywords)s" /> %(metaheaderadd)s </head> <body%(body_css_classes)s lang="%(ln_iso_639_a)s"> <div class="pageheader"> %(inspect_templates_message)s <!-- replaced page header --> <div class="headerlogo"> <table class="headerbox" cellspacing="0"> <tr> <td align="right" valign="top" colspan="12"> <div class="userinfoboxbody"> %(userinfobox)s </div> <div class="headerboxbodylogo"> <a href="%(siteurl)s?ln=%(ln)s">%(sitename)s</a> </div> </td> </tr> <tr class="menu"> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(search_selected)s"> <a class="header%(search_selected)s" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(submit_selected)s"> <a class="header%(submit_selected)s" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(personalize_selected)s"> %(useractivities)s </td> <td class="headermoduleboxbodyblank"> </td> <td class="headermoduleboxbody%(help_selected)s"> <a class="header%(help_selected)s" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> </td> %(adminactivities)s <td class="headermoduleboxbodyblanklast"> </td> </tr> </table> </div> <table class="navtrailbox"> <tr> <td class="navtrailboxbody"> %(navtrailbox)s </td> </tr> </table> <!-- end replaced page header --> %(pageheaderadd)s </div> """ % { 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'cssurl' : secure_page_p and CFG_SITE_SECURE_URL or CFG_SITE_URL, 'cssskin' : CFG_WEBSTYLE_TEMPLATE_SKIN != 'default' and '_' + CFG_WEBSTYLE_TEMPLATE_SKIN or '', 'rssurl': rssurl, 'ln' : ln, 'ln_iso_639_a' : ln.split('_', 1)[0], 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'headertitle' : cgi.escape(headertitle), 'sitesupportemail' : CFG_SITE_SUPPORT_EMAIL, 'description' : cgi.escape(description), 'keywords' : cgi.escape(keywords), 'metaheaderadd' : metaheaderadd, 'userinfobox' : userinfobox, 'navtrailbox' : navtrailbox, 'useractivities': useractivities_menu, 'adminactivities': adminactivities_menu and ('<td class="headermoduleboxbodyblank"> </td><td class="headermoduleboxbody%(personalize_selected)s">%(adminactivities)s</td>' % \ {'personalize_selected': navmenuid.startswith('admin') and "selected" or "", 'adminactivities': adminactivities_menu}) or '<td class="headermoduleboxbodyblank"> </td>', 'pageheaderadd' : pageheaderadd, 'body_css_classes' : body_css_classes and ' class="%s"' % ' '.join(body_css_classes) or '', 'search_selected': navmenuid == 'search' and "selected" or "", 'submit_selected': navmenuid == 'submit' and "selected" or "", 'personalize_selected': navmenuid.startswith('your') and "selected" or "", 'help_selected': navmenuid == 'help' and "selected" or "", 'msg_search' : _("Search"), 'msg_submit' : _("Submit"), 'msg_personalize' : _("Personalize"), 'msg_help' : _("Help"), 'languagebox' : self.tmpl_language_selection_box(req, ln), 'unAPIurl' : cgi.escape('%s/unapi' % CFG_SITE_URL), 'inspect_templates_message' : inspect_templates_message } return out
class WebInterfaceYourAlertsPages(WebInterfaceDirectory): """Defines the set of /youralerts pages.""" _exports = [ '', 'display', 'input', 'modify', 'list', 'add', 'update', 'remove' ] def index(self, req, dummy): """Index page.""" redirect_to_url(req, '%s/youralerts/list' % CFG_SITE_SECURE_URL) def display(self, req, form): """Display search history page. A misnomer.""" argd = wash_urlargd(form, {'p': (str, "n")}) uid = getUid(req) # load the right language _ = gettext_set_language(argd['ln']) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/display" % \ (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url( req, "%s/youraccount/login%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( { 'referer': "%s/youralerts/display%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( argd, {})), "ln": argd['ln'] }, {}))) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) if argd['p'] == 'y': _title = _("Popular Searches") else: _title = _("Your Searches") # register event in webstat if user_info['email']: user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["display", "", user_str]) except: register_exception( suffix= "Do the webstat tables exists? Try with 'webstatadmin --load-config'" ) return page( title=_title, body=webalert.perform_display(argd['p'], uid, ln=argd['ln']), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account': _("Your Account"), }, description=_("%s Personalize, Display searches") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts', secure_page_p=1) def input(self, req, form): argd = wash_urlargd( form, { 'idq': (int, None), 'name': (str, ""), 'freq': (str, "week"), 'notif': (str, "y"), 'idb': (int, 0), 'error_msg': (str, ""), }) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/input" % \ (CFG_SITE_SECURE_URL,), navmenuid="youralerts") elif uid == -1 or isGuestUser(uid): return redirect_to_url( req, "%s/youraccount/login%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( { 'referer': "%s/youralerts/input%s" % (CFG_SITE_SECURE_URL, make_canonical_urlargd( argd, {})), "ln": argd['ln'] }, {}))) # load the right language _ = gettext_set_language(argd['ln']) user_info = collect_user_info(req) if not user_info['precached_usealerts']: return page_not_authorized(req, "../", \ text = _("You are not authorized to use alerts.")) try: html = webalert.perform_input_alert("add", argd['idq'], argd['name'], argd['freq'], argd['notif'], argd['idb'], uid, ln=argd['ln']) except webalert.AlertError, msg: return page( title=_("Error"), body=webalert_templates.tmpl_errorMsg(ln=argd['ln'], error_msg=msg), navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account': _("Your Account"), }, description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts') if argd['error_msg'] != "": html = webalert_templates.tmpl_errorMsg( ln=argd['ln'], error_msg=argd['error_msg'], rest=html, ) # register event in webstat alert_str = "%s (%d)" % (argd['name'], argd['idq']) if user_info['email']: user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["input", alert_str, user_str]) except: register_exception( suffix= "Do the webstat tables exists? Try with 'webstatadmin --load-config'" ) return page( title=_("Set a new alert"), body=html, navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account': _("Your Account"), }, description=_("%s Personalize, Set a new alert") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts')
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != '$Date$': if lastupdated.startswith("$Date: ") or \ lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(\ convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" out = """ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> :: <a class="footer" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(msg_personalize)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> <br /> %(msg_poweredby)s <a class="footer" href="http://invenio-software.org/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> %(languagebox)s </div> <!-- replaced page footer --> </div> </body> </html> """ % { 'siteurl': CFG_SITE_URL, 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': ln, 'langlink': '?ln=' + ln, 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail': CFG_SITE_SUPPORT_EMAIL, 'msg_search': _("Search"), 'msg_submit': _("Submit"), 'msg_personalize': _("Personalize"), 'msg_help': _("Help"), 'msg_poweredby': _("Powered by"), 'msg_maintainedby': _("Maintained by"), 'msg_lastupdated': msg_lastupdated, 'languagebox': self.tmpl_language_selection_box(req, ln), 'version': CFG_VERSION, 'pagefooteradd': pagefooteradd, } return out
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != '$Date$': if lastupdated.startswith("$Date: ") or \ lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(\ convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" out = """ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> <br /> %(msg_poweredby)s <a class="footer" href="http://cdsware.cern.ch/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> %(languagebox)s </div> <!-- replaced page footer --> </div> </body> </html> """ % { 'siteurl' : CFG_SITE_URL, 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln' : ln, 'langlink': '?ln=' + ln, 'sitename' : CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail' : '*****@*****.**', 'msg_search' : _("Search"), 'msg_help' : _("Help"), 'msg_poweredby' : _("Powered by"), 'msg_maintainedby' : _("Problems/Questions to"), 'msg_lastupdated' : msg_lastupdated, 'languagebox' : self.tmpl_language_selection_box(req, ln), 'version' : self.trim_version(CFG_VERSION), 'pagefooteradd' : pagefooteradd, } return out
def format_element(bfo): """ Display administration links for this articles when user is an editor of the journal """ out = '' stats_admin_link = '' if bfo.user_info['uri'].startswith('/journal'): # Print editing links args = parse_url_string(bfo.user_info['uri']) journal_name = args["journal_name"] editor = False if acc_authorize_action(bfo.user_info['uid'], 'cfgwebjournal', name="%s" % journal_name)[0] == 0: editor = True issue_number = args["issue"] if editor: recid = bfo.control_field('001') (doctype, identifier_element, identifier_field) = \ get_journal_submission_params(journal_name) if identifier_field.startswith('00'): identifier = bfo.control_field(identifier_field) else: identifier = bfo.field(identifier_field) (auth_code, auth_msg) = acc_authorize_action(bfo.user_info, 'runwebstatadmin') if not auth_code: # User will be allowed to see stats stats_admin_link = ''' <p> <a href="%(CFG_SITE_URL)s/stats/customevent?ids=journals&cols0=articleid&col_value0=%(recid)s&timespan=last+month"> » statistics</a> </p> ''' % { 'CFG_SITE_URL': CFG_SITE_URL, 'recid': recid } out += ''' <div style="float:right;margin-left:5px;font-weight:700;"> <p> <a href="%(CFG_SITE_URL)s/submit/direct?%(identifier_element)s=%(identifier)s&sub=MBI%(doctype)s" target="_blank"> » edit article</a> </p> <p> <a href="%(CFG_SITE_URL)s/%(CFG_SITE_RECORD)s/%(recid)s" target="_blank"> » record in %(CFG_SITE_NAME_INTL)s</a> </p> <p> <a href="%(CFG_SITE_URL)s/admin/webjournal/webjournaladmin.py/regenerate?journal_name=%(journal_name)s&issue=%(issue_number)s"> » publish changes</a> </p> %(stats_admin_link)s </div>''' % { 'CFG_SITE_URL': CFG_SITE_URL, 'CFG_SITE_RECORD': CFG_SITE_RECORD, 'identifier': identifier, 'recid': recid, 'journal_name': journal_name, 'issue_number': issue_number, 'doctype': doctype, 'identifier_element': identifier_element, 'CFG_SITE_NAME_INTL': CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME), 'stats_admin_link': stats_admin_link } return out
def registerUser(req, email, passw, nickname, register_without_nickname=False, login_method=None, ln=CFG_SITE_LANG): """Register user with the desired values of NICKNAME, EMAIL and PASSW. If REGISTER_WITHOUT_NICKNAME is set to True, then ignore desired NICKNAME and do not set any. This is suitable for external authentications so that people can login without having to register an internal account first. Return 0 if the registration is successful, 1 if email is not valid, 2 if nickname is not valid, 3 if email is already in the database, 4 if nickname is already in the database, 5 when users cannot register themselves because of the site policy, 6 when the site is having problem contacting the user. If login_method is None or is equal to the key corresponding to local authentication, then CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS is taken in account for deciding the behaviour about registering. """ # is email valid? email = email.lower() if not email_valid_p(email): return 1 _ = gettext_set_language(ln) # is email already taken? res = run_sql("SELECT email FROM user WHERE email=%s", (email, )) if len(res) > 0: return 3 if register_without_nickname: # ignore desired nick and use default empty string one: nickname = "" else: # is nickname valid? if not nickname_valid_p(nickname): return 2 # is nickname already taken? res = run_sql("SELECT nickname FROM user WHERE nickname=%s", (nickname, )) if len(res) > 0: return 4 activated = 1 # By default activated if not login_method or not CFG_EXTERNAL_AUTHENTICATION[ login_method]: # local login if CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 2: return 5 elif CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: activated = 2 # Email confirmation required elif CFG_ACCESS_CONTROL_LEVEL_ACCOUNTS >= 1: activated = 0 # Administrator confirmation required if CFG_ACCESS_CONTROL_NOTIFY_USER_ABOUT_NEW_ACCOUNT: address_activation_key = mail_cookie_create_mail_activation(email) ip_address = req.remote_host or req.remote_ip try: if not send_email( CFG_SITE_SUPPORT_EMAIL, email, _("Account registration at %s") % CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), tmpl.tmpl_account_address_activation_email_body( email, address_activation_key, ip_address, ln)): return 1 except (smtplib.SMTPException, socket.error): return 6 # okay, go on and register the user: user_preference = get_default_user_preferences() uid = run_sql( "INSERT INTO user (nickname, email, password, note, settings, last_login) " "VALUES (%s,%s,AES_ENCRYPT(email,%s),%s,%s, NOW())", (nickname, email, passw, activated, serialize_via_marshal(user_preference))) if activated == 1: # Ok we consider the user as logged in :-) setUid(req, uid) return 0
def send_email(self, req, form): # set all the declared query fields as local variables args = wash_urlargd(form, {'p_email': (str, None)}) uid = webuser.getUid(req) # load the right message language _ = gettext_set_language(args['ln']) if uid == -1 or CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return webuser.page_not_authorized(req, "../youraccount/send_email", navmenuid='youraccount') user_prefs = webuser.get_user_preferences(webuser.emailUnique(args['p_email'])) if user_prefs: if user_prefs['login_method'] in CFG_EXTERNAL_AUTHENTICATION and \ CFG_EXTERNAL_AUTHENTICATION[user_prefs['login_method']] is not None: eMsg = _("Cannot send password reset request since you are using external authentication system.") return page(title=_("Your Account"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') try: reset_key = mail_cookie_create_pw_reset(args['p_email'], cookie_timeout=timedelta(days=CFG_WEBSESSION_RESET_PASSWORD_EXPIRE_IN_DAYS)) except InvenioWebAccessMailCookieError: reset_key = None if reset_key is None: eMsg = _("The entered email address does not exist in the database.") return page(title=_("Your Account"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') ip_address = req.remote_host or req.remote_ip if not send_email(CFG_SITE_SUPPORT_EMAIL, args['p_email'], "%s %s" % (_("Password reset request for"), CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), websession_templates.tmpl_account_reset_password_email_body( args['p_email'],reset_key, ip_address, args['ln'])): eMsg = _("The entered email address is incorrect, please check that it is written correctly (e.g. [email protected]).") return page(title=_("Incorrect email address"), body=webaccount.perform_emailMessage(eMsg, args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount') return page(title=_("Reset password link sent"), body=webaccount.perform_emailSent(args['p_email'], args['ln']), description="%s Personalize, Main page" % CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME), keywords=_("%(x_name)s, personalize", x_name=CFG_SITE_NAME_INTL.get(args['ln'], CFG_SITE_NAME)), uid=uid, req=req, secure_page_p = 1, language=args['ln'], lastupdated='', navmenuid='youraccount')
def tmpl_pagefooter(self, req=None, ln=CFG_SITE_LANG, lastupdated=None, pagefooteradd=""): """Creates a page footer Parameters: - 'ln' *string* - The language to display - 'lastupdated' *string* - when the page was last updated - 'pagefooteradd' *string* - additional page footer HTML code Output: - HTML code of the page headers """ # load the right message language _ = gettext_set_language(ln) if lastupdated and lastupdated != '$Date$': if lastupdated.startswith("$Date: ") or \ lastupdated.startswith("$Id: "): lastupdated = convert_datestruct_to_dategui(\ convert_datecvs_to_datestruct(lastupdated), ln=ln) msg_lastupdated = _("Last updated") + ": " + lastupdated else: msg_lastupdated = "" out = """ <div class="pagefooter"> %(pagefooteradd)s <!-- replaced page footer --> <div class="pagefooterstripeleft"> <!-- %(sitename)s :: <a class="footer" href="%(siteurl)s/?ln=%(ln)s">%(msg_search)s</a> :: <a class="footer" href="%(siteurl)s/submit?ln=%(ln)s">%(msg_submit)s</a> :: <a class="footer" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(msg_personalize)s</a> :: <a class="footer" href="%(siteurl)s/help/%(langlink)s">%(msg_help)s</a> <br />--> %(msg_poweredby)s <a class="footer" href="http://invenio-software.org/">Invenio</a> v%(version)s <br /> %(msg_maintainedby)s <a class="footer" href="mailto:%(sitesupportemail)s">%(sitesupportemail)s</a> <br /> %(msg_lastupdated)s </div> <div class="pagefooterstriperight"> <p><em> Articles in the SCOAP3 repository are released under a <a target="_blank" rel="license" href="http://creativecommons.org/licenses/by/3.0/"><strong>CC-BY</strong></a> license. Metadata are provided by the corresponding publishers and released under the <a target="_blank" rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/"> <strong>CC0</strong> </a> waiver. </em></p> %(languagebox)s </div> <!-- replaced page footer --> </div> <!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; _paq.push(["trackPageView"]); _paq.push(["enableLinkTracking"]); (function() { var u=(("https:" == document.location.protocol) ? "https" : "http") + "://cds-piwik.cern.ch/"; _paq.push(["setTrackerUrl", u+"piwik.php"]); _paq.push(["setSiteId", "10"]); var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); })(); </script> <noscript> <!-- Piwik Image Tracker --> <img src="https://cds-piwik.cern.ch/piwik.php?idsite=10&rec=1" style="border:0" alt="" /> <!-- End Piwik --> </noscript> <!-- End Piwik Code --> </body> </html> """ % { 'siteurl': CFG_BASE_URL, 'sitesecureurl': CFG_SITE_SECURE_URL, 'ln': ln, 'langlink': '?ln=' + ln, 'sitename': CFG_SITE_NAME_INTL.get(ln, CFG_SITE_NAME), 'sitesupportemail': CFG_SITE_SUPPORT_EMAIL, 'msg_search': _("Search"), 'msg_submit': _("Submit"), 'msg_personalize': _("Personalize"), 'msg_help': _("Help"), 'msg_poweredby': _("Powered by"), 'msg_maintainedby': _("Maintained by"), 'msg_lastupdated': msg_lastupdated, 'languagebox': self.tmpl_language_selection_box(req, ln), 'version': CFG_VERSION, 'pagefooteradd': pagefooteradd, } return out
def format_element(bfo, var=''): ''' Print several server specific variables. @param var: the name of the desired variable. Can be one of: CFG_SITE_NAME, CFG_SITE_NAME_INTL, CFG_SITE_LANG, CFG_VERSION, CFG_SITE_ADMIN_EMAIL, CFG_SITE_SUPPORT_EMAIL, CFG_SITE_URL, searchurl, recurl CFG_SITE_NAME: the name of the server CFG_SITE_NAME_INTL: internationalized name CFG_SITE_LANG: the default language of the server CFG_VERSION: the software version CFG_SITE_ADMIN_EMAIL: the admin email CFG_SITE_SUPPORT_EMAIL: the support email CFG_SITE_URL: the base url for the server searchurl: the search url for the server recurl: the base url for the record recinternaldoiurl_or_recurl: the base url for the record, as an internal CFG_SITE_URL + '/doi' URL when DOI is available and matched by CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN ''' dois = [] if var == 'recinternaldoiurl_or_recurl': # Prepare list of internal DOIs of that record dois = [doi for doi in record_extract_dois(bfo.get_record()) if \ re.compile(CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN).match(doi)] recID = bfo.recID if var == '': out = '' elif var in ['name', 'CFG_SITE_NAME']: out = CFG_SITE_NAME elif var in ['i18n_name', 'CFG_SITE_NAME_INTL']: out = CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME) elif var in ['lang', 'CFG_SITE_LANG']: out = CFG_SITE_LANG elif var == 'CFG_VERSION': out = 'Invenio v' + str(CFG_VERSION) elif var in ['email', 'admin_email', 'CFG_SITE_ADMIN_EMAIL']: out = CFG_SITE_ADMIN_EMAIL elif var in ['support_email', 'CFG_SITE_SUPPORT_EMAIL']: out = CFG_SITE_SUPPORT_EMAIL elif var in ['CFG_SITE_RECORD']: out = CFG_SITE_RECORD elif var in ['weburl', 'CFG_SITE_URL']: out = CFG_SITE_URL if not out.endswith('/'): out += '/' elif var in ['CFG_BASE_URL']: out = CFG_BASE_URL if not out.endswith('/'): out += '/' elif var == 'searchurl': out = CFG_BASE_URL + '/search' if not out.endswith('/'): out += '/' elif var == 'absolutesearchurl': out = CFG_SITE_URL + '/search' if not out.endswith('/'): out += '/' elif var == 'absoluterecurl': out = CFG_SITE_URL if not out.endswith('/'): out += '/' out += CFG_SITE_RECORD + '/' + str(recID) elif var == 'recinternaldoiurl_or_recurl' and \ dois: out = CFG_SITE_URL if not out.endswith('/'): out += '/' out += 'doi/' + urllib.quote(dois[0]) elif var in ('recurl', 'recinternaldoiurl_or_recurl'): out = CFG_SITE_URL if not out.endswith('/'): out += '/' out += CFG_SITE_RECORD + '/' + str(recID) else: out = 'Unknown variable: %s' % (var) return out
user_str = "%s (%d)" % (user_info['email'], user_info['uid']) else: user_str = "" try: register_customevent("alerts", ["modify", alert_str, user_str]) except: register_exception(suffix="Do the webstat tables exists? Try with 'webstatadmin --load-config'") return page(title=_("Modify alert settings"), body=html, navtrail= """<a class="navtrail" href="%(sitesecureurl)s/youraccount/display?ln=%(ln)s">%(account)s</a>""" % { 'sitesecureurl' : CFG_SITE_SECURE_URL, 'ln': argd['ln'], 'account' : _("Your Account"), }, description=_("%s Personalize, Modify alert settings") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), keywords=_("%s, personalize") % CFG_SITE_NAME_INTL.get(argd['ln'], CFG_SITE_NAME), uid=uid, language=argd['ln'], req=req, lastupdated=__lastupdated__, navmenuid='youralerts') def list(self, req, form): argd = wash_urlargd(form, {}) uid = getUid(req) if CFG_ACCESS_CONTROL_LEVEL_SITE >= 1: return page_not_authorized(req, "%s/youralerts/list" % \