fix open graph for blog, url and image path was incorrect
This commit is contained in:
parent
e13e413915
commit
77a38f1da8
|
@ -414,6 +414,7 @@ INSTALLED_APPS += ('django_extensions', )
|
||||||
INSTALLED_APPS += ('storages', )
|
INSTALLED_APPS += ('storages', )
|
||||||
INSTALLED_APPS += ('gunicorn', )
|
INSTALLED_APPS += ('gunicorn', )
|
||||||
STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", )
|
STATICFILES_FINDERS += ("compressor.finders.CompressorFinder", )
|
||||||
|
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
|
||||||
|
|
||||||
# Location of root django.contrib.admin URL, use {% url 'admin:index' %}
|
# Location of root django.contrib.admin URL, use {% url 'admin:index' %}
|
||||||
ADMIN_URL = '^trustee/'
|
ADMIN_URL = '^trustee/'
|
||||||
|
@ -516,6 +517,7 @@ TWITTER_ACCESS_TOKEN=env('TWITTER_ACCESS_TOKEN')
|
||||||
TWITTER_ACCESS_SECRET=env('TWITTER_ACCESS_SECRET')
|
TWITTER_ACCESS_SECRET=env('TWITTER_ACCESS_SECRET')
|
||||||
|
|
||||||
|
|
||||||
|
AWS_DEFAULT_ACL = None
|
||||||
AWS_S3_OBJECT_PARAMETERS = {
|
AWS_S3_OBJECT_PARAMETERS = {
|
||||||
'CacheControl': 'max-age=86400',
|
'CacheControl': 'max-age=86400',
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,12 +118,12 @@ AWS_S3_SECURE_URLS = True
|
||||||
STATIC_URL = '%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME)
|
STATIC_URL = '%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME)
|
||||||
|
|
||||||
|
|
||||||
STATICFILES_STORAGE = 'mhackspace.core.storage.SassStorageFix'
|
#STATICFILES_STORAGE = 'mhackspace.core.storage.SassStorageFix'
|
||||||
|
|
||||||
# COMPRESSOR
|
# COMPRESSOR
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True)
|
||||||
COMPRESS_STORAGE = STATICFILES_STORAGE
|
COMPRESS_STORAGE = STATICFILES_STORAGE
|
||||||
DEBUG_TOOLBAR_CONFIG = {
|
DEBUG_TOOLBAR_CONFIG = {
|
||||||
'INTERCEPT_REDIRECTS': True,
|
'INTERCEPT_REDIRECTS': False,
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,41 +10,66 @@ from mhackspace.blog.serializers import PostSerializer, CategorySerializer
|
||||||
|
|
||||||
|
|
||||||
class BlogPost(DetailView):
|
class BlogPost(DetailView):
|
||||||
context_object_name = 'post'
|
context_object_name = "post"
|
||||||
queryset = Post.objects.filter(active=True, members_only=False) # todo: check member status here
|
queryset = Post.objects.filter(active=True, members_only=False)
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super(BlogPost, self).get_context_data(*args, **kwargs)
|
||||||
|
context["open_graph"] = {
|
||||||
|
"image": self.object.image,
|
||||||
|
"title": self.object.title,
|
||||||
|
"type": "blog",
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
class PostList(ListView):
|
class PostList(ListView):
|
||||||
context_object_name = 'posts'
|
context_object_name = "posts"
|
||||||
paginate_by = 5
|
paginate_by = 5
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if 'category' in self.kwargs:
|
if "category" in self.kwargs:
|
||||||
self.category = get_object_or_404(Category, slug=self.kwargs['category'])
|
self.category = get_object_or_404(
|
||||||
return Post.objects.filter(active=True, categories=self.category, published_date__lte=timezone.now(), members_only=False)
|
Category, slug=self.kwargs["category"]
|
||||||
return Post.objects.filter(active=True, published_date__lte=timezone.now(), members_only=False)
|
)
|
||||||
|
return Post.objects.filter(
|
||||||
|
active=True,
|
||||||
|
categories=self.category,
|
||||||
|
published_date__lte=timezone.now(),
|
||||||
|
members_only=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Post.objects.filter(
|
||||||
|
active=True, published_date__lte=timezone.now(), members_only=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PostFilter(FilterSet):
|
class PostFilter(FilterSet):
|
||||||
published_date = DateTimeFromToRangeFilter(widget=RangeWidget(attrs={'placeholder': 'dd/mm/yyyy hh:mm'}))
|
published_date = DateTimeFromToRangeFilter(
|
||||||
updated_date = DateTimeFromToRangeFilter(widget=RangeWidget(attrs={'placeholder': 'dd/mm/yyyy hh:mm'}))
|
widget=RangeWidget(attrs={"placeholder": "dd/mm/yyyy hh:mm"})
|
||||||
|
)
|
||||||
|
updated_date = DateTimeFromToRangeFilter(
|
||||||
|
widget=RangeWidget(attrs={"placeholder": "dd/mm/yyyy hh:mm"})
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Post
|
model = Post
|
||||||
fields = ('title', 'slug', 'author__name', 'published_date', 'updated_date')
|
fields = (
|
||||||
|
"title", "slug", "author__name", "published_date", "updated_date"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PostViewSet(viewsets.ModelViewSet):
|
class PostViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Post.objects.filter(active=True)
|
queryset = Post.objects.filter(active=True)
|
||||||
filter_class = PostFilter
|
filter_class = PostFilter
|
||||||
serializer_class = PostSerializer
|
serializer_class = PostSerializer
|
||||||
search_fields = ('title', 'slug', 'categories', 'author__name')
|
search_fields = ("title", "slug", "categories", "author__name")
|
||||||
ordering_fields = ('title', 'published_date', 'updated_date', 'author')
|
ordering_fields = ("title", "published_date", "updated_date", "author")
|
||||||
|
|
||||||
|
|
||||||
class CategoryViewSet(viewsets.ModelViewSet):
|
class CategoryViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Category.objects.all()
|
queryset = Category.objects.all()
|
||||||
serializer_class = CategorySerializer
|
serializer_class = CategorySerializer
|
||||||
search_fields = ('name', 'slug')
|
search_fields = ("name", "slug")
|
||||||
ordering_fields = ('name', 'slug')
|
ordering_fields = ("name", "slug")
|
||||||
filter_fields = ('name', 'slug')
|
filter_fields = ("name", "slug")
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
{% block css %}{% endblock %}
|
{% block css %}{% endblock %}
|
||||||
|
|
||||||
{% block head-open-graph %}
|
{% block head-open-graph %}
|
||||||
<meta property="og:title" content="Maidstone Hackspace" />
|
<meta property="og:title" content="Maidstone Hackspace{% if open_graph.title %} - {{open_graph.title}}{% endif %}" />
|
||||||
<meta property="og:type" content="website" />
|
<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:url" content="{{ request.build_absolute_uri }}" />
|
||||||
<meta property="og:image" content="https://maidstone-hackspace.org.uk/static/images/android-chrome-192x192.png" />
|
<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 %}" />
|
||||||
{% endblock head-open-graph %}
|
{% endblock head-open-graph %}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue