Add open graph data to the wiki and other pages
This commit is contained in:
parent
9c23136214
commit
83c71485db
|
@ -4,7 +4,10 @@
|
|||
[[https://pyup.io/repos/github/maidstone-hackspace/maidstone-hackspace-website/][https://pyup.io/repos/github/maidstone-hackspace/maidstone-hackspace-website/shield.svg]]
|
||||
|
||||
Repository for the maidstone hackspace website, feel free to fork this site for your own Hackspace.
|
||||
|
||||
** Social
|
||||
Test site sharing links / cards with twitter and facebook
|
||||
https://cards-dev.twitter.com/validator
|
||||
https://developers.facebook.com/tools/debug/
|
||||
** Requirements
|
||||
Before getting started make sure you have git, docker and docker-compose installed on your machine.
|
||||
The simplest way to setup this site is to use docker-compose so please install that from this site
|
||||
|
|
|
@ -22,6 +22,7 @@ APPS_DIR = ROOT_DIR.path('mhackspace')
|
|||
env = environ.Env()
|
||||
env.read_env('%s/.env' % ROOT_DIR)
|
||||
|
||||
# Start ST is Spirit forum software config
|
||||
ST_TOPIC_PRIVATE_CATEGORY_PK = 1
|
||||
ST_RATELIMIT_ENABLE = True
|
||||
ST_RATELIMIT_CACHE_PREFIX = 'srl'
|
||||
|
@ -49,6 +50,8 @@ ST_UPLOAD_FILE_ENABLED = True
|
|||
# Tests helpers
|
||||
ST_TESTS_RATELIMIT_NEVER_EXPIRE = False
|
||||
ST_BASE_DIR = os.path.dirname(__file__)
|
||||
# END ST is Spirit forum software config
|
||||
|
||||
|
||||
SECRET_KEY = env('DJANGO_SECRET_KEY', default='wq)sg12k&5&adv)e%56n5e97o@))6xu90b**=-w+)d^c+cd9%1')
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ STATIC_URL = '%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME)
|
|||
|
||||
# COMPRESSOR
|
||||
# ------------------------------------------------------------------------------
|
||||
#COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||
#COMPRESS_STORAGE = STATICFILES_STORAGE
|
||||
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||
COMPRESS_STORAGE = STATICFILES_STORAGE
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'INTERCEPT_REDIRECTS': False,
|
||||
}
|
||||
|
|
|
@ -23,8 +23,10 @@ from mhackspace.blog.sitemaps import PostSitemap, CategorySitemap
|
|||
from mhackspace.feeds.views import FeedViewSet, ArticleViewSet
|
||||
from mhackspace.requests.views import RequestsForm, RequestsList, RequestsDetail, RequestsDetailForm
|
||||
from mhackspace.rfid.views import DeviceViewSet, AuthUserWithDeviceViewSet
|
||||
from mhackspace.core.views import ChatView, AboutView
|
||||
|
||||
from mhackspace.register.views import RegisterForm
|
||||
from mhackspace.wiki.urls import CustomWikiUrlPatterns
|
||||
|
||||
from wiki.urls import get_pattern as get_wiki_pattern
|
||||
from django_nyt.urls import get_pattern as get_nyt_pattern
|
||||
|
@ -47,8 +49,8 @@ sitemaps = {
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
|
||||
url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name='about'),
|
||||
url(r'^chat/$', TemplateView.as_view(template_name='pages/chat.html'), name='chat'),
|
||||
url(r'^about/$', AboutView.as_view(template_name='pages/about.html'), name='about'),
|
||||
url(r'^chat/$', ChatView.as_view(template_name='pages/chat.html'), name='chat'),
|
||||
url(r'^mailing-list/$', TemplateView.as_view(template_name='pages/mailing-list.html'), name='group'),
|
||||
url(r'^contact/$', contact, name='contact'),
|
||||
|
||||
|
@ -110,7 +112,7 @@ urlpatterns = [
|
|||
|
||||
urlpatterns += [
|
||||
url(r'^notifications/', get_nyt_pattern()),
|
||||
url(r'^wiki/', get_wiki_pattern(), name='wiki')
|
||||
url(r'^wiki/', get_wiki_pattern(url_config_class=CustomWikiUrlPatterns), name='wiki')
|
||||
]
|
||||
if settings.DEBUG:
|
||||
# This allows the error pages to be debugged during development, just visit
|
||||
|
|
|
@ -19,6 +19,7 @@ class BlogPost(DetailView):
|
|||
"image": self.object.image,
|
||||
"title": self.object.title,
|
||||
"type": "blog",
|
||||
"description": self.object.excerpt,
|
||||
}
|
||||
return context
|
||||
|
||||
|
|
|
@ -6,21 +6,24 @@ from mhackspace.contact.forms import ContactForm
|
|||
|
||||
def contact(request):
|
||||
form_class = ContactForm
|
||||
if request.method == 'POST':
|
||||
if request.method == "POST":
|
||||
form = form_class(data=request.POST)
|
||||
if form.is_valid():
|
||||
data = form.cleaned_data
|
||||
email = EmailMessage(
|
||||
'[%s] - %s' % (data['enquiry_type'], data['subject']),
|
||||
data['message'],
|
||||
data['contact_email'],
|
||||
to=['contact@maidstone-hackspace.org.uk'],
|
||||
headers={'Reply-To': data['contact_email']})
|
||||
"[%s] - %s" % (data["enquiry_type"], data["subject"]),
|
||||
data["message"],
|
||||
data["contact_email"],
|
||||
to=["contact@maidstone-hackspace.org.uk"],
|
||||
headers={"Reply-To": data["contact_email"]},
|
||||
)
|
||||
email.send()
|
||||
messages.add_message(request, messages.INFO, 'E-Mail sent')
|
||||
messages.add_message(request, messages.INFO, "E-Mail sent")
|
||||
else:
|
||||
form = form_class()
|
||||
|
||||
return render(request, 'pages/contact.html', {
|
||||
'form': form,
|
||||
})
|
||||
return render(
|
||||
request,
|
||||
"pages/contact.html",
|
||||
{"form": form, "open_graph": {"title": "Contact Us", "type": "article"}},
|
||||
)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ChatView(TemplateView):
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context["open_graph"] = {
|
||||
"title": "Chat with us",
|
||||
"type": "website",
|
||||
"description": "Speak to members of the Hackspace directly.",
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
class AboutView(TemplateView):
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context["open_graph"] = {
|
||||
"title": "About Us",
|
||||
"type": "article",
|
||||
"description": "Useful information about Maidstone Hackspace.",
|
||||
}
|
||||
return context
|
|
@ -32,7 +32,10 @@
|
|||
<meta property="og:title" content="Maidstone Hackspace{% if open_graph.title %} - {{open_graph.title}}{% endif %}" />
|
||||
<meta property="og:type" content="{% if open_graph.type %}{{open_graph.type}}{% else %}website{% endif %}" />
|
||||
<meta property="og:url" content="{{ request.build_absolute_uri }}" />
|
||||
<meta property="og:image" content="{% if open_graph.image %}{{open_graph.image.full.url}}{% else %}https://maidstone-hackspace.org.uk/static/images/android-chrome-192x192.png{% endif %}" />
|
||||
<meta property="og:image" content="{% if open_graph.image %}{{open_graph.image.full.url}}{% else %}{% static 'images/android-chrome-192x192.png' %}{% endif %}" />
|
||||
{% if open_graph.description %}
|
||||
<meta property="og:description" content="{{open_graph.description}}" />
|
||||
{% endif %}
|
||||
{% endblock head-open-graph %}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
from wiki.urls import WikiURLPatterns
|
||||
from mhackspace.wiki.views import WikiArticleView
|
||||
|
||||
|
||||
class CustomWikiUrlPatterns(WikiURLPatterns):
|
||||
article_view_class = WikiArticleView
|
|
@ -0,0 +1,13 @@
|
|||
from wiki.views.article import ArticleView
|
||||
|
||||
|
||||
class WikiArticleView(ArticleView):
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context["open_graph"] = {
|
||||
"image": "", # self.article.image,
|
||||
"title": self.article.current_revision.title,
|
||||
"type": "article",
|
||||
"description": self.article.current_revision.content,
|
||||
}
|
||||
return context
|
Loading…
Reference in New Issue