From 9c032c3d855cb001926b80bf14529fd9fdd9fe69 Mon Sep 17 00:00:00 2001
From: Mary Kate Fain
Date: Oct 02 2018 15:43:56 +0000
Subject: [PATCH 1/4] Contact information added to Errors, fixes #3372
A new contact page template has been created, is linked in eact theme's footer
The default contact page includes links to submit a bug, and contact the pagure lists
Errors now include a link to the contact page to help users get help
---
diff --git a/dev/ansible/roles/pagure-dev/files/pagure.cfg b/dev/ansible/roles/pagure-dev/files/pagure.cfg
index 6640aac..714325f 100644
--- a/dev/ansible/roles/pagure-dev/files/pagure.cfg
+++ b/dev/ansible/roles/pagure-dev/files/pagure.cfg
@@ -97,7 +97,7 @@ SHORT_LENGTH = 6
### or other
BLACKLISTED_PROJECTS = [
'static', 'pv', 'releases', 'new', 'api', 'settings',
- 'logout', 'login', 'users', 'groups', 'projects']
+ 'logout', 'login', 'users', 'groups', 'projects', 'contact']
### IP addresses allowed to access the internal endpoints
### These endpoints are used by the milter and are security sensitive, thus
diff --git a/pagure/contact.md b/pagure/contact.md
new file mode 100644
index 0000000..1cd9476
--- /dev/null
+++ b/pagure/contact.md
@@ -0,0 +1,10 @@
+# Contact
+---
+
+
+
+If you experience a bug or security concern, please [submit an issue](https://pagure.io/pagure/issues).
+
+You may also post questions to the Pagure Development list by emailing: [pagure-devel@lists.pagure.io](mailto:pagure-devel@lists.pagure.io) or [subscribe to the list](https://lists.pagure.io/admin/lists/pagure-devel.lists.pagure.io/).
+
+[Subscribe to announcements](https://lists.pagure.io/admin/lists/pagure-announce.lists.pagure.io/) about Pagure.
diff --git a/pagure/static/upload.js b/pagure/static/upload.js
index 5d7e8ef..438968a 100644
--- a/pagure/static/upload.js
+++ b/pagure/static/upload.js
@@ -91,7 +91,7 @@ function doUpload(csrf_token, files) {
if ( !text || text === "" ) {
text = '
An error occured when uploading your file. Could it be '
+ 'that it exceeds the maximum limit allowed?
'
- + '
Please contact an admin if this problem persist or is '
+ + '
Please contact an admin if this problem persist or is '
+ 'blocking you. Thanks!
';
}
var _elt = $('
' + text + '
');
diff --git a/pagure/templates/contact.html b/pagure/templates/contact.html
new file mode 100644
index 0000000..133381f
--- /dev/null
+++ b/pagure/templates/contact.html
@@ -0,0 +1,94 @@
+{% extends "master.html" %}
+
+{% block title %}About{% endblock %}
+{% set tag = "about" %}
+
+{% from "_browseheader.html" import browse_header %}
+{% from "_projectstring.html" import projectstring, projecticon %}
+
+
+{% block header %}
+
+{% endblock %}
+
+{% block content %}
+
+
diff --git a/pagure/themes/default/templates/theme.html b/pagure/themes/default/templates/theme.html
index 8aa2f70..7abd1e1 100644
--- a/pagure/themes/default/templates/theme.html
+++ b/pagure/themes/default/templates/theme.html
@@ -17,10 +17,10 @@ href="{{ url_for('theme.static', filename='favicon.ico')}}?version={{ g.version}
{% endmacro %}
{% macro browseheader_message(select) %}
- {#
+ {#
message that shows at the top of the browse pages:
'select' is the browse page. It can be either: 'projects',
- 'users', or 'groups'.
+ 'users', or 'groups'.
#}
{% if select == 'projects' %}
diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index b49c908..8151156 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -14,6 +14,8 @@ from __future__ import unicode_literals
import datetime
import logging
from math import ceil
+import markdown
+import os
import flask
from sqlalchemy.exc import SQLAlchemyError
@@ -1489,3 +1491,26 @@ def force_logout():
flask.g.session.commit()
flask.flash("All active sessions logged out")
return flask.redirect(flask.url_for("ui_ns.user_settings"))
+
+
+@UI_NS.route("/contact")
+@UI_NS.route("/contact/")
+def contact():
+ """ A page to direct users to the appropriate places to get help.
+ """
+
+ if pagure_config.get("CONTACT_PAGE_PATH"):
+ file_path = pagure_config["CONTACT_PAGE_PATH"]
+
+ else:
+ file_path = os.path.join(
+ os.path.abspath(os.path.dirname(__file__)), "..", "contact.md"
+ )
+
+ with open(file_path) as file:
+ content = file.read()
+
+ return flask.render_template(
+ "contact.html",
+ content=markdown.markdown(content)
+ )
diff --git a/pagure/ui/fas_login.py b/pagure/ui/fas_login.py
index a11cc16..86c5583 100644
--- a/pagure/ui/fas_login.py
+++ b/pagure/ui/fas_login.py
@@ -13,6 +13,7 @@ from __future__ import unicode_literals
import logging
import flask
+from flask import Markup
from sqlalchemy.exc import SQLAlchemyError
@@ -115,9 +116,12 @@ def set_user(return_url):
except SQLAlchemyError as err:
flask.g.session.rollback()
_log.exception(err)
+ message = Markup(
+ 'Could not set up you as a user properly,'
+ ' please contact an administrator'
+ )
flask.flash(
- "Could not set up you as a user properly, please contact "
- "an admin",
+ message,
"error",
)
# Ensure the user is logged out if we cannot set them up
diff --git a/pagure/ui/oidc_login.py b/pagure/ui/oidc_login.py
index f746b04..d818691 100644
--- a/pagure/ui/oidc_login.py
+++ b/pagure/ui/oidc_login.py
@@ -13,6 +13,7 @@ from __future__ import unicode_literals
import logging
import flask
+from flask import Markup
import munch
from sqlalchemy.exc import SQLAlchemyError
@@ -131,9 +132,12 @@ def set_user():
except SQLAlchemyError as err:
flask.g.session.rollback()
_log.exception(err)
+ message = Markup(
+ 'Could not set up you as a user properly,'
+ ' please contact an administrator'
+ )
flask.flash(
- "Could not set up you as a user properly, please contact "
- "an admin",
+ message,
"error",
)
# Ensure the user is logged out if we cannot set them up
diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py
index ea35c4a..6cdd638 100644
--- a/pagure/ui/plugins.py
+++ b/pagure/ui/plugins.py
@@ -16,6 +16,8 @@ from __future__ import unicode_literals
import logging
import flask
+from flask import Markup
+
from sqlalchemy.exc import SQLAlchemyError
import pagure.exceptions
@@ -126,8 +128,12 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True):
except SQLAlchemyError as err: # pragma: no cover
flask.g.session.rollback()
_log.exception("Could not add plugin %s", plugin.name)
+ message = Markup(
+ 'Could not add plugin,'
+ ' please contact an administrator'
+ )
flask.flash(
- "Could not add plugin %s, please contact an admin"
+ message
% plugin.name
)
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index e2635e4..aab7ace 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -27,6 +27,7 @@ import re
from math import ceil
import flask
+from flask import Markup
import pygit2
import kitchen.text.converters as ktc
import six
@@ -2384,8 +2385,13 @@ def revoke_api_token(repo, token_id, username=None, namespace=None):
except SQLAlchemyError as err: # pragma: no cover
flask.g.session.rollback()
_log.exception(err)
+ message = Markup(
+ 'Token could not be revoked,'
+ ' please contact an administrator'
+ )
flask.flash(
- "Token could not be revoked, please contact an admin", "error"
+ message,
+ "error"
)
return flask.redirect(
From 50b2d4a4ab32afc770cacab6f42af654a4ad8e3e Mon Sep 17 00:00:00 2001
From: Mary Kate Fain
Date: Oct 02 2018 21:23:57 +0000
Subject: [PATCH 2/4] moved contact.md to new about_page theme macro
---
diff --git a/dev/ansible/roles/pagure-dev/files/pagure.cfg b/dev/ansible/roles/pagure-dev/files/pagure.cfg
index 714325f..c1fa516 100644
--- a/dev/ansible/roles/pagure-dev/files/pagure.cfg
+++ b/dev/ansible/roles/pagure-dev/files/pagure.cfg
@@ -97,7 +97,7 @@ SHORT_LENGTH = 6
### or other
BLACKLISTED_PROJECTS = [
'static', 'pv', 'releases', 'new', 'api', 'settings',
- 'logout', 'login', 'users', 'groups', 'projects', 'contact']
+ 'logout', 'login', 'users', 'groups', 'projects', 'about']
### IP addresses allowed to access the internal endpoints
### These endpoints are used by the milter and are security sensitive, thus
diff --git a/doc/configuration.rst b/doc/configuration.rst
index eb35b98..e3b96cc 100644
--- a/doc/configuration.rst
+++ b/doc/configuration.rst
@@ -836,7 +836,7 @@ Defaults to:
[
'static', 'pv', 'releases', 'new', 'api', 'settings',
- 'logout', 'login', 'users', 'groups'
+ 'logout', 'login', 'users', 'groups', 'about'
]
diff --git a/doc/usage/theming.rst b/doc/usage/theming.rst
index 2daf8c1..2d1d4fb 100644
--- a/doc/usage/theming.rst
+++ b/doc/usage/theming.rst
@@ -148,7 +148,7 @@ this needs to be included in this macro in your theme. Example:
######################
An optional Jinja macro that defines the welcome message that is shown
-above the tabs on the Browse Pages (Projects, Users, and Groups). The
+above the tabs on the Browse Pages (Projects, Users, and Groups). The
select parameter is a string with the name of the page being shown
Example:
@@ -187,3 +187,21 @@ A Jinja macro that defines the footer of the Pagure site. Example:
{% endmacro %}
+
+
+`about_page()` macro
+######################
+
+A Jinja macro that defines the content of the About page (available at /about). You may want to replace the links to contact links for your own instance. Example:
+
+::
+
+ {% macro about_page() %}
+
+
About
+
This is an instance of Pagure, a decentralized git forge.
+
If you experience a bug or security concern, please submit an issue.
+ {% endmacro %}
diff --git a/pagure/contact.md b/pagure/contact.md
deleted file mode 100644
index 1cd9476..0000000
--- a/pagure/contact.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Contact
----
-
-
-
-If you experience a bug or security concern, please [submit an issue](https://pagure.io/pagure/issues).
-
-You may also post questions to the Pagure Development list by emailing: [pagure-devel@lists.pagure.io](mailto:pagure-devel@lists.pagure.io) or [subscribe to the list](https://lists.pagure.io/admin/lists/pagure-devel.lists.pagure.io/).
-
-[Subscribe to announcements](https://lists.pagure.io/admin/lists/pagure-announce.lists.pagure.io/) about Pagure.
diff --git a/pagure/static/upload.js b/pagure/static/upload.js
index 438968a..b0d1a11 100644
--- a/pagure/static/upload.js
+++ b/pagure/static/upload.js
@@ -91,7 +91,7 @@ function doUpload(csrf_token, files) {
if ( !text || text === "" ) {
text = '
An error occured when uploading your file. Could it be '
+ 'that it exceeds the maximum limit allowed?
+{% endmacro %}
diff --git a/pagure/ui/app.py b/pagure/ui/app.py
index 8151156..4d40b01 100644
--- a/pagure/ui/app.py
+++ b/pagure/ui/app.py
@@ -1493,24 +1493,12 @@ def force_logout():
return flask.redirect(flask.url_for("ui_ns.user_settings"))
-@UI_NS.route("/contact")
-@UI_NS.route("/contact/")
-def contact():
- """ A page to direct users to the appropriate places to get help.
+@UI_NS.route("/about")
+@UI_NS.route("/about/")
+def help():
+ """ A page to direct users to the appropriate places to get assistance,
+ or find basic instance information.
"""
-
- if pagure_config.get("CONTACT_PAGE_PATH"):
- file_path = pagure_config["CONTACT_PAGE_PATH"]
-
- else:
- file_path = os.path.join(
- os.path.abspath(os.path.dirname(__file__)), "..", "contact.md"
- )
-
- with open(file_path) as file:
- content = file.read()
-
return flask.render_template(
- "contact.html",
- content=markdown.markdown(content)
+ "about.html",
)
diff --git a/pagure/ui/fas_login.py b/pagure/ui/fas_login.py
index 86c5583..58e6e2c 100644
--- a/pagure/ui/fas_login.py
+++ b/pagure/ui/fas_login.py
@@ -118,7 +118,7 @@ def set_user(return_url):
_log.exception(err)
message = Markup(
'Could not set up you as a user properly,'
- ' please contact an administrator'
+ ' please contact an administrator'
)
flask.flash(
message,
diff --git a/pagure/ui/oidc_login.py b/pagure/ui/oidc_login.py
index d818691..1b5dbd1 100644
--- a/pagure/ui/oidc_login.py
+++ b/pagure/ui/oidc_login.py
@@ -134,7 +134,7 @@ def set_user():
_log.exception(err)
message = Markup(
'Could not set up you as a user properly,'
- ' please contact an administrator'
+ ' please contact an administrator'
)
flask.flash(
message,
diff --git a/pagure/ui/plugins.py b/pagure/ui/plugins.py
index 6cdd638..8886fbb 100644
--- a/pagure/ui/plugins.py
+++ b/pagure/ui/plugins.py
@@ -130,7 +130,7 @@ def view_plugin(repo, plugin, username=None, namespace=None, full=True):
_log.exception("Could not add plugin %s", plugin.name)
message = Markup(
'Could not add plugin,'
- ' please contact an administrator'
+ ' please contact an administrator'
)
flask.flash(
message
diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py
index aab7ace..f9c2b52 100644
--- a/pagure/ui/repo.py
+++ b/pagure/ui/repo.py
@@ -2387,7 +2387,7 @@ def revoke_api_token(repo, token_id, username=None, namespace=None):
_log.exception(err)
message = Markup(
'Token could not be revoked,'
- ' please contact an administrator'
+ ' please contact an administrator'
)
flask.flash(
message,
From 04a0dcd691a69d29c121f6e1e92d3426380581a6 Mon Sep 17 00:00:00 2001
From: Mary Kate Fain
Date: Oct 04 2018 17:51:09 +0000
Subject: [PATCH 3/4] removed unused code, changed about language, allowed admin_email to be set as a confguration
---
diff --git a/doc/configuration.rst b/doc/configuration.rst
index e3b96cc..46c5cca 100644
--- a/doc/configuration.rst
+++ b/doc/configuration.rst
@@ -1126,6 +1126,14 @@ Defaults to: ``Pagure``
.. note: the welcome screen currently does not work with the `local`
authentication.
+ADMIN_EMAIL
+~~~~~~~~~~~
+
+This configuration key allows you to change the default administrator email
+which is displayed on the "about" page. It can also be used elsewhere.
+
+Defaults to: ``pagure-devel@lists.pagure.io``
+
USER_NAMESPACE
~~~~~~~~~~~~~~
diff --git a/doc/usage/theming.rst b/doc/usage/theming.rst
index 2d1d4fb..578e6e2 100644
--- a/doc/usage/theming.rst
+++ b/doc/usage/theming.rst
@@ -199,7 +199,7 @@ A Jinja macro that defines the content of the About page (available at /about).
{% macro about_page() %}
About
-
This is an instance of Pagure, a decentralized git forge.
+
This is an instance of Pagure, a git forge.
If you experience a bug or security concern, please submit an issue.