diff --git a/__pycache__/build.cpython-36.pyc b/__pycache__/build.cpython-36.pyc new file mode 100644 index 00000000..0ce94728 Binary files /dev/null and b/__pycache__/build.cpython-36.pyc differ diff --git a/build.py b/build.py index 0345a22f..fb16c506 100644 --- a/build.py +++ b/build.py @@ -288,9 +288,15 @@ def page_category(slug): """ title = '%s — %d Funny, Clean %s' % (c['name'], len(js), c['name']) desc = '%s %s %d jokes, all clean and all terrible. Perfect for dads, teachers and any occasion that needs a groan.' % (c['blurb'], 'Browse', len(js)) - ld = {"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ - {"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'}, - {"@type": "ListItem", "position": 2, "name": c['name'], "item": SITE_URL + '/category/%s/' % slug}]} + ld = [ + {"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ + {"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'}, + {"@type": "ListItem", "position": 2, "name": c['name'], "item": SITE_URL + '/category/%s/' % slug}]}, + {"@context": "https://schema.org", "@type": "ItemList", "itemListElement": [ + {"@type": "ListItem", "position": i + 1, "url": f"{SITE_URL}/#joke-{j['id']}"} + for i, j in enumerate(js) + ]} + ] return layout(title, desc, body, '/category/%s/' % slug, '' % esc(json.dumps(ld))) diff --git a/count.py b/count.py new file mode 100644 index 00000000..22554407 --- /dev/null +++ b/count.py @@ -0,0 +1,10 @@ +import json, collections, re +with open("content/jokes.json") as f: + data = json.load(f) +jokes = data["jokes"] +words = collections.Counter() +for j in jokes: + for word in re.findall(r"\b\w+\b", j["setup"].lower() + " " + j["punch"].lower()): + if len(word) > 4: + words[word] += 1 +print(words.most_common(50)) diff --git a/fix.py b/fix.py new file mode 100644 index 00000000..604b3b52 --- /dev/null +++ b/fix.py @@ -0,0 +1,23 @@ +import sys +with open('/home/opc/REPOS/bestdadjokes/build.py', 'r') as f: + lines = f.readlines() + +start_idx = 290 +end_idx = 291 + +new_code = """ ld = [ + {"@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [ + {"@type": "ListItem", "position": 1, "name": "Home", "item": SITE_URL + '/'}, + {"@type": "ListItem", "position": 2, "name": c['name'], "item": SITE_URL + '/category/%s/' % slug}]}, + {"@context": "https://schema.org", "@type": "ItemList", "itemListElement": [ + {"@type": "ListItem", "position": i + 1, "url": f"{SITE_URL}/#joke-{j['id']}"} + for i, j in enumerate(js) + ]} + ] + return layout(title, desc, body, '/category/%s/' % slug, + '' % esc(json.dumps(ld))) +""" + +lines = lines[:start_idx] + [new_code] + lines[end_idx:] +with open('/home/opc/REPOS/bestdadjokes/build.py', 'w') as f: + f.writelines(lines) diff --git a/nginx.conf b/nginx.conf index 22f3212c..68068f99 100644 --- a/nginx.conf +++ b/nginx.conf @@ -14,9 +14,7 @@ http { listen 80; root /usr/share/nginx/html; index index.html; - error_page 404 /404.html; - add_header X-Content-Type-Options nosniff always; - add_header Referrer-Policy strict-origin-when-cross-origin always; + error_page 404 /404.html;\n add_header Strict-Transport-Security \"max-age=31536000; includeSubDomains\" always;\n add_header X-Frame-Options \"DENY\" always;\n add_header X-Content-Type-Options nosniff always;\n add_header Referrer-Policy strict-origin-when-cross-origin always;\n add_header Permissions-Policy \"geolocation=(), microphone=(), camera=()\" always; location ~* \.(css|js|svg|png|jpg|ico|woff2?)$ { expires 7d; add_header Cache-Control "public"; diff --git a/site/api/v1/random.json b/site/api/v1/random.json index d76e54b6..627fded6 100644 --- a/site/api/v1/random.json +++ b/site/api/v1/random.json @@ -1 +1 @@ -{"setup": "Why is everyone so excited about the cat's new job?", "punchline": "Because it's feline good.", "type": "qa", "category": "animals", "source": "https://bestdadjokes.lol/category/animals/#joke-286"} \ No newline at end of file +{"setup": "Why did the invisible man turn down the job offer?", "punchline": "He couldn't see himself doing it.", "type": "qa", "category": "work", "source": "https://bestdadjokes.lol/category/work/#joke-324"} \ No newline at end of file diff --git a/site/api/v1/today.json b/site/api/v1/today.json index 23aa482e..b212516e 100644 --- a/site/api/v1/today.json +++ b/site/api/v1/today.json @@ -1 +1 @@ -{"setup": "What time did the man go to the dentist?", "punchline": "Tooth hurty.", "type": "line", "category": "one-liners", "source": "https://bestdadjokes.lol/category/one-liners/#joke-248"} \ No newline at end of file +{"setup": "Why don't skeletons ever fight each other?", "punchline": "They don't have the guts.", "type": "qa", "category": "halloween", "source": "https://bestdadjokes.lol/category/halloween/#joke-186"} \ No newline at end of file diff --git a/site/category/animals/index.html b/site/category/animals/index.html index 15341877..f5d49f55 100644 --- a/site/category/animals/index.html +++ b/site/category/animals/index.html @@ -12,20 +12,20 @@ -Animal Dad Jokes — 43 Funny, Clean Animal Dad Jokes - +Animal Dad Jokes — 44 Funny, Clean Animal Dad Jokes + - - + + - +