forked from 00dani/lemoncurry
Install django-rq and use it to ping WebSub, rather than blocking the micropub request during pings
This commit is contained in:
parent
382b7ee4a9
commit
e853e22362
6 changed files with 81 additions and 47 deletions
11
Pipfile
11
Pipfile
|
@ -12,11 +12,11 @@ python_version = '3.6'
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
|
|
||||||
Django = "*"
|
django = "*"
|
||||||
django_compressor = "*"
|
django-compressor = "*"
|
||||||
gunicorn = "*"
|
gunicorn = "*"
|
||||||
"psycopg2" = "*"
|
"psycopg2" = "*"
|
||||||
Pillow = "*"
|
pillow = "*"
|
||||||
python-memcached = "*"
|
python-memcached = "*"
|
||||||
django-favicon-plus = "*"
|
django-favicon-plus = "*"
|
||||||
django-meta = "*"
|
django-meta = "*"
|
||||||
|
@ -27,18 +27,19 @@ qrcode = "*"
|
||||||
django-otp-agents = "*"
|
django-otp-agents = "*"
|
||||||
python-slugify = "*"
|
python-slugify = "*"
|
||||||
"mf2py" = "*"
|
"mf2py" = "*"
|
||||||
Markdown = "*"
|
markdown = "*"
|
||||||
bleach = "*"
|
bleach = "*"
|
||||||
django-debug-toolbar = "*"
|
django-debug-toolbar = "*"
|
||||||
xrd = "*"
|
xrd = "*"
|
||||||
django-push = "*"
|
django-push = "*"
|
||||||
PyYAML = "*"
|
pyyaml = "*"
|
||||||
django-annoying = "*"
|
django-annoying = "*"
|
||||||
django-shorturls = "*"
|
django-shorturls = "*"
|
||||||
accept-types = "*"
|
accept-types = "*"
|
||||||
django-analytical = "*"
|
django-analytical = "*"
|
||||||
django-model-utils = "*"
|
django-model-utils = "*"
|
||||||
python-jose = "*"
|
python-jose = "*"
|
||||||
|
django-rq = "*"
|
||||||
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
97
Pipfile.lock
generated
97
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "cf182403fb7c87c0f9836e227d4179fb82098b79f3766497a26d10a9c3b2663a"
|
"sha256": "47ed3b4022e12ce5fcdf671cdc9e8512a30c925745dd07a2385d951c3f1a4315"
|
||||||
},
|
},
|
||||||
"host-environment-markers": {
|
"host-environment-markers": {
|
||||||
"implementation_name": "cpython",
|
"implementation_name": "cpython",
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
"os_name": "posix",
|
"os_name": "posix",
|
||||||
"platform_machine": "x86_64",
|
"platform_machine": "x86_64",
|
||||||
"platform_python_implementation": "CPython",
|
"platform_python_implementation": "CPython",
|
||||||
"platform_release": "17.2.0",
|
"platform_release": "17.3.0",
|
||||||
"platform_system": "Darwin",
|
"platform_system": "Darwin",
|
||||||
"platform_version": "Darwin Kernel Version 17.2.0: Sun Oct 1 00:46:50 PDT 2017; root:xnu-4570.20.62~10/RELEASE_X86_64",
|
"platform_version": "Darwin Kernel Version 17.3.0: Wed Oct 25 22:42:12 PDT 2017; root:xnu-4570.30.81.0.1~1/RELEASE_X86_64",
|
||||||
"python_full_version": "3.6.3",
|
"python_full_version": "3.6.3",
|
||||||
"python_version": "3.6",
|
"python_version": "3.6",
|
||||||
"sys_platform": "darwin"
|
"sys_platform": "darwin"
|
||||||
|
@ -52,10 +52,10 @@
|
||||||
},
|
},
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:54a07c09c586b0e4c619f02a5e94e36619da8e2b053e20f594348c0611803704",
|
"sha256:244be0d93b71e93fc0a0a479862051414d0e00e16435707e5bf5000f92e04694",
|
||||||
"sha256:40523d2efb60523e113b44602298f0960e900388cf3bb6043f645cf57ea9e3f5"
|
"sha256:5ec74291ca1136b40f0379e1128ff80e866597e4e2c1e755739a913bbc3613c0"
|
||||||
],
|
],
|
||||||
"version": "==2017.7.27.1"
|
"version": "==2017.11.5"
|
||||||
},
|
},
|
||||||
"chardet": {
|
"chardet": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -64,6 +64,13 @@
|
||||||
],
|
],
|
||||||
"version": "==3.0.4"
|
"version": "==3.0.4"
|
||||||
},
|
},
|
||||||
|
"click": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
|
||||||
|
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
|
||||||
|
],
|
||||||
|
"version": "==6.7"
|
||||||
|
},
|
||||||
"django": {
|
"django": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:75ce405d60f092f6adf904058d023eeea0e6d380f8d9c36134bac73da736023d",
|
"sha256:75ce405d60f092f6adf904058d023eeea0e6d380f8d9c36134bac73da736023d",
|
||||||
|
@ -178,6 +185,13 @@
|
||||||
],
|
],
|
||||||
"version": "==1.7.1"
|
"version": "==1.7.1"
|
||||||
},
|
},
|
||||||
|
"django-rq": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:7cd517c3e243603c8e5b24bfc4797d57d751a4ba1b471124157e9822a83335a2",
|
||||||
|
"sha256:368051f0a3ef08670dd186ea0202cbc7644e199fd48fd31eace2e637e915a7f7"
|
||||||
|
],
|
||||||
|
"version": "==0.9.6"
|
||||||
|
},
|
||||||
"django-shorturls": {
|
"django-shorturls": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:382ff617b36fea04981b30457377a46f2034d0940a40a20c6f637c55ea0bda93"
|
"sha256:382ff617b36fea04981b30457377a46f2034d0940a40a20c6f637c55ea0bda93"
|
||||||
|
@ -206,10 +220,10 @@
|
||||||
},
|
},
|
||||||
"html5lib": {
|
"html5lib": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:b8934484cf22f1db684c0fae27569a0db404d0208d20163fbf51cc537245d008",
|
"sha256:08a3efc117a4fc8c82c3c6d10d6f58ae266428d57ed50258a1466d2cd88de745",
|
||||||
"sha256:ee747c0ffd3028d2722061936b5c65ee4fe13c8e4613519b4447123fc4546298"
|
"sha256:0d5fd54d5b2b79b876007a70c033a4023577768d18022c15681c00561432a0f9"
|
||||||
],
|
],
|
||||||
"version": "==0.999999999"
|
"version": "==1.0b10"
|
||||||
},
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -227,36 +241,36 @@
|
||||||
},
|
},
|
||||||
"lxml": {
|
"lxml": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:7a8715539adb41c78129983ba69d852e0102a3f51d559eeb91dce1f6290c4ad0",
|
"sha256:41f59cbdab232f11680d5d4dec9f2e6782fd24d78e37ee833447702e34e675f4",
|
||||||
"sha256:d3a98dda9831a37ef7f55c5e69c0d276c278f24978f5b36b9fad7eac05a22bfc",
|
"sha256:e7e41d383f19bab9d57f5f3b18d158655bcd682e7e723f441b9e183e1e35a6b5",
|
||||||
"sha256:1deacd52638da2d7fcb864c3949f0285638ec10e6aace93ce15c6a2e0ed91b95",
|
"sha256:155521c337acecf8202091cff85bb9f709f238130ebadf04280fb1db11f5ad8b",
|
||||||
"sha256:1548247ea3b50014a3ea55ad9446108df191b6a6e51aa8f5953c95b663f382ff",
|
"sha256:d2c985d2460b81c6ca5feb8b86f1bc594ad59405d0bdf68626b85852b701553c",
|
||||||
"sha256:5da6f5b31ea2b573cb20e88aefc6b49d849d07588ba60871342cae42f569b0d7",
|
"sha256:950e63387514aa1b881eba5ac6cb2ec51a118b3dafe99dd80ca19d8fb0142f30",
|
||||||
"sha256:12e348eb57fb79ccf91a49b7b937c49a5bbe1d73ba75589674b76a56d064bda0",
|
"sha256:470d7ce41e8047208ba1a376560bad17f1468df1f3097bc83902b26cfafdbb0c",
|
||||||
"sha256:b9e1735918fc1e83c522b9f1048e6bc5af38af958e4efc843046e4b0075a021b",
|
"sha256:e608839a5ee2180164424ccf279c8e2d9bbe8816d002c58fd97d6b621ba4aa94",
|
||||||
"sha256:fafeb4b190bd63ba2bcee2496d99cb7345fafbace6b999403010abdff8c05b72",
|
"sha256:87a66bcadac270fc010cb029022a93fc722bf1204a8b03e782d4c790f0edf7ca",
|
||||||
"sha256:9007da6fb1b96fb1c9d7bd65e97bbbad60295abc19833d7e67e05314c1868f58",
|
"sha256:2dedfeeecc2d5a939cf622602f5a1ce443ca82407f386880f739f1a9f08053ad",
|
||||||
"sha256:cfbf0b956f33cda3af2a1438a2541549b69a7a240e71de7d8ca819b8f1547aac",
|
"sha256:ba05732e4bcf59e948f61588851dcf620fd60d5bbd9d704203e5f59bbaa60219",
|
||||||
"sha256:0a103253a94cdad86028d273aaebb8b30c75fdf009c23e52cdc8ce88429fd326",
|
"sha256:2190266059fec3c5a55f9d6c30532c64c6d414d3228909c0af573fe4907e78d1",
|
||||||
"sha256:b3d5a0ecf0c2c31c404246b6706b2e477159ee07b73be5102389ab250dd67701",
|
"sha256:dd291debfaa535d9cb6cee8d7aca2328775e037d02d13f1634e57f49bc302cc4",
|
||||||
"sha256:e92af0fd08c7d2176ad4be4a7c47fd800d6ee05046b41e36ed579c01fb106c25",
|
"sha256:29a36e354c39b2e24bc4ee103de53417ebb80f976a6ab9e8d093d559e2ac03e1",
|
||||||
"sha256:feb2144c2ae4035ad57165dd22bdc93b1389158a985c0497a096d39e2b2cd67b",
|
"sha256:e37427d5a27eefbcfc48847e0b37f348113fac7280bc857421db39ffc6372570",
|
||||||
"sha256:a4433655219b84a360dbdf2c34d9625c3988a272e6fc028222d528ad5902f6a2",
|
"sha256:b106d4d2383382399ad82108fd187e92f40b1c90f55c2d36bbcb1c44bcf940fc",
|
||||||
"sha256:db98287cb1488eb103930a64444542f6ffe83694ef392f801aa56d648d905663",
|
"sha256:0ee07da52d240f1dc3c83eef5cd5f1b7f018226c1121f2a54d446645779a6d17",
|
||||||
"sha256:307d325ee143b60b9c82912e96e9f4345200c33c8ae00b04b001e4c85fb5f146",
|
"sha256:3b33549fb8f91b38a7500078242b03cca513f3412a2cdae722e89bf83f95971d",
|
||||||
"sha256:5caec9b174dbf927034d588669c62d2a9d0ce447365b20a3463f4daab1e4f03b",
|
"sha256:4c12e90886d9c53ab434c8d0cebea122321cce19614c3c6b6d1a7700d7cc6212",
|
||||||
"sha256:fb816595494ce21191764572215f56edfbc6d9fbebd1491c8466502892989689",
|
"sha256:79322000279cda10b53c374d53ca632ead3bc51c6aebf8e62c8fa93a4d08b750",
|
||||||
"sha256:10399bececdb67f0d9251ecf2dda2abf6ddeee6096741754356f1a3715c8c830",
|
"sha256:6cba398eb37e0631e60e0e080c101cfe91769b2c8267105b64b4625e2581ea21",
|
||||||
"sha256:c263fd15d27f3be93485fcd83a495cbbc35352512d9e31644d49a54504a1be2a",
|
"sha256:49a655956f8de69e1258bc0fcfc43eb3bd1e038655784d77d1869b4b81444e37",
|
||||||
"sha256:c10ad53216d5af2b3ba63e65db793cb7dd7e598e17826938045e32f38b0e4814",
|
"sha256:af8a5373241d09b8fc53e0490e1719ce5dc90a21b19db89b6596c1adcdd52270",
|
||||||
"sha256:d42a5182d4b0953d02e5f46c9f0dc304be736fbaa1c0d2f11326182b9684b5f4",
|
"sha256:e6b6698415c7e8d227a47a3b1038e1b37c2b438a1b48c2db7ad9e74ddbcd1149",
|
||||||
"sha256:dd7c22bf890d266e72c5e5c8c44555ffbfe4ca2a329da785e7d8b1972fc3ff74",
|
"sha256:155c916cf2645b4a8f2bd5d09065e92d1b67b8d464bdc001e0b524af84bedf6f",
|
||||||
"sha256:93df9805146980e83834ea9320baa6a56d8aea45f63d7d3cc721f71eb1a1bac6",
|
"sha256:fa7320679ced5e25b20203d157280680fc84eb783b6cc650cb0c98e1858b7dd3",
|
||||||
"sha256:7ba1b62fe9414d73d493241011df952b72074808debc3a2d6d8a64fb9944edf6",
|
"sha256:4187c4b0cefc3353181db048c51f42c489d9ac51e40b86c4851dc0671372971d",
|
||||||
"sha256:d2c121f5f77bed1e1eddeee23ee76fee8a3d48fa7a3aab589d12942f87778a9e",
|
"sha256:d5d29663e979e83b3fc361e97200f959cddb3a14797391d15273d84a5a8ae44b",
|
||||||
"sha256:be3aaeb5f468a49f523f16736ccff7d82af2b4b303292ba3d052b5b28f3fbe47"
|
"sha256:940caef1ec7c78e0c34b0f6b94fe42d0f2022915ffc78643d28538a5cfd0f40e"
|
||||||
],
|
],
|
||||||
"version": "==4.1.0"
|
"version": "==4.1.1"
|
||||||
},
|
},
|
||||||
"markdown": {
|
"markdown": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
|
@ -456,6 +470,13 @@
|
||||||
],
|
],
|
||||||
"version": "==1.0.12"
|
"version": "==1.0.12"
|
||||||
},
|
},
|
||||||
|
"rq": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:aa9e73113713e3b2e8d633ebb5f8ceccf5c8c97c1aae4356dc3f46d446129f71",
|
||||||
|
"sha256:ae5b4507de1be3db4e737c3d59179c568b2906539f5eacaff218e5bb6b05937b"
|
||||||
|
],
|
||||||
|
"version": "==0.9.1"
|
||||||
|
},
|
||||||
"six": {
|
"six": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",
|
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb",
|
||||||
|
|
8
entries/jobs.py
Normal file
8
entries/jobs.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django_push import publisher
|
||||||
|
from django_rq import job
|
||||||
|
|
||||||
|
|
||||||
|
@job
|
||||||
|
def ping_hub(*urls):
|
||||||
|
for url in urls:
|
||||||
|
publisher.ping_hub(url)
|
|
@ -77,6 +77,7 @@ INSTALLED_APPS = [
|
||||||
'django_agent_trust',
|
'django_agent_trust',
|
||||||
'django_otp',
|
'django_otp',
|
||||||
'django_otp.plugins.otp_totp',
|
'django_otp.plugins.otp_totp',
|
||||||
|
'django_rq',
|
||||||
'favicon',
|
'favicon',
|
||||||
'meta',
|
'meta',
|
||||||
'shorturls',
|
'shorturls',
|
||||||
|
@ -228,3 +229,7 @@ META_USE_TWITTER_PROPERTIES = True
|
||||||
# django-push
|
# django-push
|
||||||
# https://django-push.readthedocs.io/en/latest/publisher.html
|
# https://django-push.readthedocs.io/en/latest/publisher.html
|
||||||
PUSH_HUB = 'https://00dani.superfeedr.com/'
|
PUSH_HUB = 'https://00dani.superfeedr.com/'
|
||||||
|
|
||||||
|
# django-rq
|
||||||
|
# https://github.com/ui/django-rq
|
||||||
|
RQ_QUEUES = {'default': {'USE_REDIS_CACHE': 'default'}}
|
||||||
|
|
|
@ -42,6 +42,7 @@ urlpatterns = [
|
||||||
url('^micropub', include('micropub.urls')),
|
url('^micropub', include('micropub.urls')),
|
||||||
url('^s/', include('shorturls.urls')),
|
url('^s/', include('shorturls.urls')),
|
||||||
|
|
||||||
|
url(r'^django-rq/', include('django_rq.urls')),
|
||||||
url(r'^sitemap\.xml$', sitemap.index, maps, name='sitemap'),
|
url(r'^sitemap\.xml$', sitemap.index, maps, name='sitemap'),
|
||||||
url(r'^sitemaps/(?P<section>.+)\.xml$', sitemap.sitemap, maps,
|
url(r'^sitemaps/(?P<section>.+)\.xml$', sitemap.sitemap, maps,
|
||||||
name='django.contrib.sitemaps.views.sitemap'),
|
name='django.contrib.sitemaps.views.sitemap'),
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django_push.publisher import ping_hub
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
|
from entries.jobs import ping_hub
|
||||||
from entries.models import Entry
|
from entries.models import Entry
|
||||||
from entries.kinds import Article, Note
|
from entries.kinds import Article, Note
|
||||||
from lemoncurry import utils
|
from lemoncurry import utils
|
||||||
|
@ -43,9 +43,7 @@ def micropub(request):
|
||||||
reverse('entries:atom'),
|
reverse('entries:atom'),
|
||||||
reverse('entries:rss'),
|
reverse('entries:rss'),
|
||||||
))
|
))
|
||||||
ping_hub(perma)
|
ping_hub(perma, *others)
|
||||||
for url in others:
|
|
||||||
ping_hub(url)
|
|
||||||
|
|
||||||
res = HttpResponse(status=201)
|
res = HttpResponse(status=201)
|
||||||
res['Location'] = perma
|
res['Location'] = perma
|
||||||
|
|
Loading…
Reference in a new issue