diff --git a/README.org b/README.org index faf9720..fcda9af 100644 --- a/README.org +++ b/README.org @@ -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 diff --git a/config/settings/common.py b/config/settings/common.py index 26e90c9..2cbaa82 100644 --- a/config/settings/common.py +++ b/config/settings/common.py @@ -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') diff --git a/config/settings/local.py b/config/settings/local.py index f0f4799..9225e6c 100644 --- a/config/settings/local.py +++ b/config/settings/local.py @@ -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, } diff --git a/config/urls.py b/config/urls.py index 29aea1b..184df25 100644 --- a/config/urls.py +++ b/config/urls.py @@ -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 diff --git a/mhackspace/blog/views.py b/mhackspace/blog/views.py index 99f0d17..abd2058 100644 --- a/mhackspace/blog/views.py +++ b/mhackspace/blog/views.py @@ -19,6 +19,7 @@ class BlogPost(DetailView): "image": self.object.image, "title": self.object.title, "type": "blog", + "description": self.object.excerpt, } return context diff --git a/mhackspace/contact/views.py b/mhackspace/contact/views.py index 0cb33db..f3f8416 100644 --- a/mhackspace/contact/views.py +++ b/mhackspace/contact/views.py @@ -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"}}, + ) diff --git a/mhackspace/core/views.py b/mhackspace/core/views.py new file mode 100644 index 0000000..bb16585 --- /dev/null +++ b/mhackspace/core/views.py @@ -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 diff --git a/mhackspace/templates/base.html b/mhackspace/templates/base.html index ed01b3d..6e25638 100644 --- a/mhackspace/templates/base.html +++ b/mhackspace/templates/base.html @@ -32,7 +32,10 @@ - + + {% if open_graph.description %} + + {% endif %} {% endblock head-open-graph %} diff --git a/mhackspace/wiki/urls.py b/mhackspace/wiki/urls.py new file mode 100644 index 0000000..f18b57d --- /dev/null +++ b/mhackspace/wiki/urls.py @@ -0,0 +1,6 @@ +from wiki.urls import WikiURLPatterns +from mhackspace.wiki.views import WikiArticleView + + +class CustomWikiUrlPatterns(WikiURLPatterns): + article_view_class = WikiArticleView diff --git a/mhackspace/wiki/views.py b/mhackspace/wiki/views.py new file mode 100644 index 0000000..d465945 --- /dev/null +++ b/mhackspace/wiki/views.py @@ -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