Repository: python-discord/site

Issue:
Edit on GitHub for content articles.
At the top of an article in the `content` app, we should show an "Edit on GitHub" button.
The button when clicked should lead to the GitHub page for that file - something like https://github.com/python-discord/site/blob/main/docs/configuration.md

The button should have a nice logo, maybe an edit pencil or a github icon.
Here's one such mock implementation:
![image](https://user-images.githubusercontent.com/41782385/117431320-af211e00-af5b-11eb-9088-35ba824621ca.png)

Improvements on the mock design can be to reduce the visual weight of the button, or finding a way to make it smaller yet accessible.

Anyone who wants to implement this can propose alternative implementations, feel free to do so in `#dev-contrib` or `#dev-dewikification`.


Discussion:
We can also the put the `share` button on the article, like it is shown on the Microsoft docs you linked.
I would be willing to try and implement this as my first major contribution to the site 😁 
Assigned!

Feel free to chat with us in #dev-contrib if you get stuck at any point, we'd be happy to help!
Re: [this comment](https://github.com/python-discord/site/pull/506#issuecomment-869122708)

Can I take this if @doublevcodes is unable to finish it?
@doublevcodes has said [on discord](https://discord.com/channels/267624335836053506/635950537262759947/901810777609093130) they let me take this one. Can I get assigned please? I've almost finished my implementation with a some improvements to the original and I'll open a PR after my exams are over.

I've added `is_category` to the context so that the button would only show up on articles (weird to say "edit on github" on categories). Not sure if there are already places in the existing context that can determine whether it's a category.
@hedyhli Sorry, didn't see your comment here. As we discussed in Discord as well a while back, you're welcome to take this PR.

Thanks!

Resolving patch:
diff --git a/pydis_site/apps/content/templatetags/__init__.py b/pydis_site/apps/content/templatetags/__init__.py
new file mode 100644
diff --git a/pydis_site/apps/content/templatetags/page_src.py b/pydis_site/apps/content/templatetags/page_src.py
new file mode 100644
--- /dev/null
+++ b/pydis_site/apps/content/templatetags/page_src.py
@@ -0,0 +1,25 @@
+from django import template
+from django.conf import settings
+
+
+register = template.Library()
+
+
+@register.filter()
+def page_src_url(request_path: str) -> str:
+    """
+    Return the corresponding GitHub source URL for the current content article.
+
+    request_path is the relative path of an article, as returned by `request.path` in templates.
+
+    GitHub source URL is set in settings.py as CONTENT_SRC_URL, prefix for the
+    url which the request path would be appended to.
+
+    Assumes '.md' file extension for the page source files.
+
+    For example: /pages/rules/ would return:
+    https://github.com/python-discord/site/tree/main/pydis_site/apps/content/resources/rules.md
+    """
+    src_url = request_path.replace("/pages/", settings.CONTENT_SRC_URL)
+    src_url = src_url[:-1] + ".md"
+    return src_url
diff --git a/pydis_site/settings.py b/pydis_site/settings.py
--- a/pydis_site/settings.py
+++ b/pydis_site/settings.py
@@ -332,3 +332,8 @@
 
 # How long to wait for synchronous requests before timing out
 TIMEOUT_PERIOD = env("TIMEOUT_PERIOD")
+
+# Source files url for 'Edit on GitHub' link on content articles
+CONTENT_SRC_URL = (
+    "https://github.com/python-discord/site/tree/main/pydis_site/apps/content/resources/"
+)


Test patch: