Skip to content

Commit 172e08d

Browse files
committed
Ads.txt is now configurable
1 parent ce7b8c0 commit 172e08d

File tree

18 files changed

+69
-167
lines changed

18 files changed

+69
-167
lines changed

.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ EMAIL_PORT=587
4141
EMAIL_HOST_USER=
4242
EMAIL_HOST_PASSWORD=
4343
EMAIL_USE_TLS=True
44-
DEFAULT_FROM_EMAIL=
44+
DEFAULT_FROM_EMAIL=
45+
46+
47+
#ads.txt file content
48+
MY_ADS_TXT_CONTENT=

bloggy/.DS_Store

6 KB
Binary file not shown.

bloggy/forms/edit_profile_form.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,42 @@ class Meta:
2222
]
2323

2424
widgets = {
25-
'profile_photo': NonClearableFileInput(attrs={'class': 'form-control-file'}),
26-
'name': forms.TextInput(
27-
attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Enter first name'}),
28-
'bio': forms.Textarea(attrs={'class': 'form-control', 'rows': 3, 'placeholder': "About you"}),
29-
'website': forms.TextInput(attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Your website'}),
30-
'twitter': forms.TextInput(attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Your twitter'}),
31-
'linkedin': forms.TextInput(attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Your linkedin'}),
32-
'youtube': forms.TextInput(
33-
attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Your youtube channel link'}),
34-
'github': forms.TextInput(attrs={'class': 'form-control', 'rows': 5, 'placeholder': 'Your github'}),
25+
'profile_photo': NonClearableFileInput(attrs={
26+
'class': 'form-control-file'
27+
}),
28+
'name': forms.TextInput(attrs={
29+
'class': 'form-control',
30+
'rows': 5,
31+
'placeholder': 'Enter first name'
32+
}),
33+
'bio': forms.Textarea(attrs={
34+
'class': 'form-control',
35+
'rows': 3,
36+
'placeholder': "About you"
37+
}),
38+
'website': forms.TextInput(attrs={
39+
'class': 'form-control',
40+
'rows': 5,
41+
'placeholder': 'Your website'
42+
}),
43+
'twitter': forms.TextInput(attrs={
44+
'class': 'form-control',
45+
'rows': 5,
46+
'placeholder': 'Your twitter'
47+
}),
48+
'linkedin': forms.TextInput(attrs={
49+
'class': 'form-control',
50+
'rows': 5,
51+
'placeholder': 'Your linkedin'
52+
}),
53+
'youtube': forms.TextInput(attrs={
54+
'class': 'form-control',
55+
'rows': 5,
56+
'placeholder': 'Your youtube channel link'
57+
}),
58+
'github': forms.TextInput(attrs={
59+
'class': 'form-control',
60+
'rows': 5,
61+
'placeholder': 'Your github'
62+
}),
3563
}

bloggy/settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@
317317
}
318318
}
319319

320-
321320
# Django HitCount
322321
HITCOUNT_KEEP_HIT_ACTIVE = {'days': 0}
323322
HITCOUNT_KEEP_HIT_IN_DATABASE = {'days': 77}
@@ -329,7 +328,7 @@
329328
# SEO related
330329
PING_INDEX_NOW_POST_UPDATE = os.getenv("PING_INDEX_NOW_POST_UPDATE", True)
331330
PING_GOOGLE_POST_UPDATE = os.getenv("PING_GOOGLE_POST_UPDATE", True)
332-
INDEX_NOW_API_KEY = os.getenv("INDEX_NOW_API_KEY",)
331+
INDEX_NOW_API_KEY = os.getenv("INDEX_NOW_API_KEY", )
333332

334333
# Email configs
335334
EMAIL_BACKEND = os.getenv('EMAIL_BACKEND')
@@ -340,3 +339,6 @@
340339
EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS', True)
341340
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL')
342341
EMAIL_FILE_PATH = os.getenv('EMAIL_FILE_PATH', os.path.join(BASE_DIR, 'test-emails'))
342+
343+
# ads.txt file content
344+
MY_ADS_TXT_CONTENT = os.getenv('MY_ADS_TXT_CONTENT')

bloggy/storage_backends.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ class PublicMediaStorage(S3Boto3Storage):
1111
location = 'media'
1212
default_acl = 'public-read'
1313
file_overwrite = False
14-
# security_token = None
15-
16-
# def _get_security_token(self):
17-
# return None
1814

1915

2016
class PrivateMediaStorage(S3Boto3Storage):

bloggy/templates/ads.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

bloggy/templates/thumbnail/template.html

Lines changed: 0 additions & 39 deletions
This file was deleted.

bloggy/urls.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from .views.account import AccountActivationView
3333
from .views.article_views import ArticleListView, ArticleDetailsView
3434
from .views.login import MyLoginView
35+
from .views.misc_views import AdsTextView
3536
from .views.old_blog_redirect_view import AuthorRedirectView
3637
from .views.old_blog_redirect_view import OldCategoryDetailsRedirectView
3738
from .views.old_blog_redirect_view import OldTagArchiveRedirectView
@@ -66,29 +67,32 @@
6667
path('authors', AuthorsListView.as_view(), name="authors"),
6768
path('user/<str:username>', PublicProfileView.as_view(), name="user_profile"),
6869

69-
# path('profile', login_required(MyProfileView.as_view()), name="profile.view"),
7070
path('edit-profile', login_required(EditProfileView.as_view()), name="profile.edit_profile"),
7171
path('dashboard', login_required(MyProfileView.as_view()), name="profile.dashboard"),
7272
path('bookmarks', login_required(UserBookmarksView.as_view()), name="profile.bookmarks"),
7373

7474
path('privacy', TemplateView.as_view(template_name="pages/static/privacy-policy.html"), name='pages.privacy'),
75-
path('code-of-conduct', TemplateView.as_view(template_name="pages/static/code_of_conduct.html"), name='pages.code_of_conduct'),
75+
path('code-of-conduct', TemplateView.as_view(template_name="pages/static/code_of_conduct.html"),
76+
name='pages.code_of_conduct'),
7677
path('contribute', TemplateView.as_view(template_name="pages/static/contribute.html"), name='pages.contribute'),
7778
path('about', AboutPageView.as_view(), name='pages.about'),
7879
path('contact', TemplateView.as_view(template_name="pages/static/contact.html"), name='pages.contact'),
79-
path('terms-of-service', TemplateView.as_view(template_name="pages/static/terms-of-service.html"), name='pages.terms_of_service'),
80-
path('cookie-policy', TemplateView.as_view(template_name="pages/static/cookie-policy.html"), name='pages.cookie_policy'),
80+
path('terms-of-service', TemplateView.as_view(template_name="pages/static/terms-of-service.html"),
81+
name='pages.terms_of_service'),
82+
path('cookie-policy', TemplateView.as_view(template_name="pages/static/cookie-policy.html"),
83+
name='pages.cookie_policy'),
8184

8285
path("rss/articles", ArticlesRssFeed(), name="articles_feed"),
8386
path("rss/courses", CoursesRssFeed(), name="courses_feed"),
8487
path('sitemap.xml', index, {'sitemaps': sitemaps_list}, name='django.contrib.sitemaps.views.index'),
85-
path('sitemap/<str:section>.xml', sitemap, {'sitemaps': sitemaps_list}, name='django.contrib.sitemaps.views.sitemap'),
88+
path('sitemap/<str:section>.xml', sitemap, {'sitemaps': sitemaps_list},
89+
name='django.contrib.sitemaps.views.sitemap'),
8690

8791
# static files for SEO or other reasons
8892
path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
89-
path('ads.txt', TemplateView.as_view(template_name="ads.txt", content_type="text/plain")),
93+
path('ads.txt', AdsTextView.as_view(), name='ads_txt'),
9094
path('220764bdee4b4ff297c588217aaaafa3.txt',
91-
TemplateView.as_view(template_name="220764dee4b4ff297c588217aaaafa3.txt", content_type="text/plain")),
95+
TemplateView.as_view(template_name="220764bdee4b4ff297c588217aaaafa3.txt", content_type="text/plain")),
9296

9397
# redirects for old website migration
9498
path('author/<str:user>', AuthorRedirectView.as_view()),

bloggy/utils/http_utils.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

bloggy/views/home.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@ def get_context_data(self, **kwargs):
2323
return context
2424

2525

26-
class GuestBookView(TemplateView):
27-
template_name = "pages/static/guestbook.html"
28-
29-
def get_context_data(self, **kwargs):
30-
context = super(GuestBookView, self).get_context_data(**kwargs)
31-
32-
try:
33-
data = HttpUtils.read_file("/static/json/twitter-testimonials.json")
34-
context['data'] = data['testimonials']
35-
except Exception as e:
36-
print(e)
37-
38-
return context
39-
40-
4126
class AboutPageView(TemplateView):
4227
template_name = "pages/static/about.html"
4328

0 commit comments

Comments
 (0)