From 6ede600cefd9ff249e0a087a96b8e0fde50a5657 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Thu, 11 Apr 2019 23:51:02 +0200 Subject: New landing page. Not quite done yet. This probably should've been more than one commit. --- pydis_site/settings.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index f7668f65..7eb552cd 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -255,5 +255,6 @@ BULMA_SETTINGS = { "variables": { "primary": "#7289DA", "link": "$primary", + "navbar-height": "4.75rem", } } -- cgit v1.2.3 From 7affc403fc1a0e3ca823cb188f1bce08f221dd8a Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Fri, 12 Apr 2019 00:14:39 +0200 Subject: Implemented a sticky footer system --- pydis_site/settings.py | 1 + pydis_site/static/css/base/base.css | 11 +++++++++++ pydis_site/templates/base/base.html | 12 ++++++++---- pydis_site/templates/home/index.html | 1 - 4 files changed, 20 insertions(+), 5 deletions(-) (limited to 'pydis_site/settings.py') diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 7eb552cd..03ad6bc5 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -256,5 +256,6 @@ BULMA_SETTINGS = { "primary": "#7289DA", "link": "$primary", "navbar-height": "4.75rem", + "footer-padding": "1rem 1.5rem 1rem", } } diff --git a/pydis_site/static/css/base/base.css b/pydis_site/static/css/base/base.css index 5949725d..02ccba84 100644 --- a/pydis_site/static/css/base/base.css +++ b/pydis_site/static/css/base/base.css @@ -18,3 +18,14 @@ #pydis-text { font-weight: bold; } + + +body.site { + display: flex; + min-height: 100vh; + flex-direction: column; +} + +main.site-content { + flex: 1; +} diff --git a/pydis_site/templates/base/base.html b/pydis_site/templates/base/base.html index fecf60cc..5d5fe7ec 100644 --- a/pydis_site/templates/base/base.html +++ b/pydis_site/templates/base/base.html @@ -24,11 +24,15 @@ {% block head %}{% endblock %} - + -{% block content %} - {{ block.super }} -{% endblock %} +
+ {% block content %} + {{ block.super }} + {% endblock %} +
+ +{% include "base/footer.html" %} diff --git a/pydis_site/templates/home/index.html b/pydis_site/templates/home/index.html index 1f4da8e3..511e05e5 100644 --- a/pydis_site/templates/home/index.html +++ b/pydis_site/templates/home/index.html @@ -49,5 +49,4 @@ - {% include "base/footer.html" %} {% endblock %} -- cgit v1.2.3 From f29472a56f925127a077c4cadcc13fa852dc665b Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 13 Apr 2019 16:16:11 +0200 Subject: refactoring slightly to use a class-based view, changing home to main. Ready to write the API search stuff now. --- Pipfile | 1 + Pipfile.lock | 112 +++++++++++++++------ pydis_site/apps/home/__init__.py | 0 pydis_site/apps/home/admin.py | 3 - pydis_site/apps/home/apps.py | 5 - pydis_site/apps/home/migrations/__init__.py | 0 pydis_site/apps/home/models.py | 3 - pydis_site/apps/home/templatetags/__init__.py | 0 pydis_site/apps/home/templatetags/extra_filters.py | 8 -- pydis_site/apps/home/tests.py | 9 -- pydis_site/apps/home/urls.py | 10 -- pydis_site/apps/home/views.py | 3 - pydis_site/apps/main/__init__.py | 0 pydis_site/apps/main/admin.py | 3 + pydis_site/apps/main/apps.py | 5 + pydis_site/apps/main/migrations/__init__.py | 0 pydis_site/apps/main/models.py | 3 + pydis_site/apps/main/templatetags/__init__.py | 0 pydis_site/apps/main/templatetags/extra_filters.py | 8 ++ pydis_site/apps/main/tests.py | 9 ++ pydis_site/apps/main/urls.py | 11 ++ pydis_site/apps/main/views/__init__.py | 3 + pydis_site/apps/main/views/home.py | 47 +++++++++ pydis_site/apps/wiki/__init__.py | 0 pydis_site/apps/wiki/admin.py | 3 - pydis_site/apps/wiki/apps.py | 5 - pydis_site/apps/wiki/migrations/__init__.py | 0 pydis_site/apps/wiki/models.py | 3 - pydis_site/apps/wiki/tests.py | 3 - pydis_site/apps/wiki/views.py | 3 - pydis_site/hosts.py | 3 +- pydis_site/settings.py | 3 +- pydis_site/urls.py | 2 +- 33 files changed, 172 insertions(+), 96 deletions(-) delete mode 100644 pydis_site/apps/home/__init__.py delete mode 100644 pydis_site/apps/home/admin.py delete mode 100644 pydis_site/apps/home/apps.py delete mode 100644 pydis_site/apps/home/migrations/__init__.py delete mode 100644 pydis_site/apps/home/models.py delete mode 100644 pydis_site/apps/home/templatetags/__init__.py delete mode 100644 pydis_site/apps/home/templatetags/extra_filters.py delete mode 100644 pydis_site/apps/home/tests.py delete mode 100644 pydis_site/apps/home/urls.py delete mode 100644 pydis_site/apps/home/views.py create mode 100644 pydis_site/apps/main/__init__.py create mode 100644 pydis_site/apps/main/admin.py create mode 100644 pydis_site/apps/main/apps.py create mode 100644 pydis_site/apps/main/migrations/__init__.py create mode 100644 pydis_site/apps/main/models.py create mode 100644 pydis_site/apps/main/templatetags/__init__.py create mode 100644 pydis_site/apps/main/templatetags/extra_filters.py create mode 100644 pydis_site/apps/main/tests.py create mode 100644 pydis_site/apps/main/urls.py create mode 100644 pydis_site/apps/main/views/__init__.py create mode 100644 pydis_site/apps/main/views/home.py delete mode 100644 pydis_site/apps/wiki/__init__.py delete mode 100644 pydis_site/apps/wiki/admin.py delete mode 100644 pydis_site/apps/wiki/apps.py delete mode 100644 pydis_site/apps/wiki/migrations/__init__.py delete mode 100644 pydis_site/apps/wiki/models.py delete mode 100644 pydis_site/apps/wiki/tests.py delete mode 100644 pydis_site/apps/wiki/views.py (limited to 'pydis_site/settings.py') diff --git a/Pipfile b/Pipfile index 932746d2..bb2c88ee 100644 --- a/Pipfile +++ b/Pipfile @@ -27,6 +27,7 @@ uwsgi = "~=2.0.18" psycopg2-binary = "~=2.8" django-simple-bulma = ">=1.1.6,<2.0" django-crispy-bulma = ">=0.1.2,<2.0" +requests = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index c574a6f1..0adf7124 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "e7a956892e9d18b6ac8ab13fe8e139d29196e236fbb194f4cb8b37308ea91c6e" + "sha256": "bc1a4e553aca43f2682f1954ae00b54413613646a20585c3007c121960a86b36" }, "pipfile-spec": 6, "requires": { @@ -16,6 +16,20 @@ ] }, "default": { + "certifi": { + "hashes": [ + "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", + "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" + ], + "version": "==2019.3.9" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, "django": { "hashes": [ "sha256:7c3543e4fb070d14e10926189a7fcf42ba919263b7473dceaefce34d54e8a119", @@ -87,6 +101,13 @@ "index": "pypi", "version": "==0.2.1" }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, "libsass": { "hashes": [ "sha256:2ae3b061a7d250fb47e5fdad1a8191600ca15dc604e76b109b6d3bf8e08fd2ed", @@ -110,44 +131,52 @@ }, "psycopg2-binary": { "hashes": [ - "sha256:0c8cb1b93e25eaf1dfedbcb4cee4ce3860035ce216b71590bda5f8dc99128526", - "sha256:1c2eeb074d2be404f22a14c4c71eeaa1a855c940abedf6f726158348e9c83dd6", - "sha256:1d879395a5d0dfe191dcfc622dce8b0a5e4fb76d089c903f18a4913e5fbc79c7", - "sha256:20d47c61bc9d6a431039f6ceb3b9a34a952a1562cf718054f64c524526fb8ed8", - "sha256:39fc9323f065361b99fca7758ac723d7e66bbc7e6ec9c90e398857af0ef61404", - "sha256:3c5b7579f3075f19b0b54495d28105049d44564d67b817eef2fa561b2bcf532b", - "sha256:3f811db92e30ea2412dfba8e64b18102017646969b5f436138d7b2b38a0e8966", - "sha256:41d60c8610a70b6666641b662379ef3b847ad2acd38303d4c8e34efd0f782403", - "sha256:45979c708536a3132398863579280657c6bc77e9b9be8b05ba0dae9013b5a0a8", - "sha256:4aaa54574b52b85223d3d950b2fc77bd672e6fbb324bb99f834eacbedc4545f7", - "sha256:50647aa5f7171153a5f7fa667f99f55468b9b663b997927e4d2e83955b21aa9f", - "sha256:528175ab1f12131bb5ea0df64fc524a4c6c51c197dc68d2a9e646029890d4d0f", - "sha256:5cbb49cc1c3c4c69ba09a7e18452bd44371b6adad0c9636f117a7554660af529", - "sha256:6e2f69635b548147e9b9298f5b67155d212f742683e51d78d24ceec4a3f5464d", - "sha256:7994d43431f1b9eba5daa1bdb8f626482cf01e379c00967092c6ebb3e4d3235f", - "sha256:86ec556a75f7e0124581100f2c4c8f9c8d67fc6254af4ce500633a77a4ca3207", - "sha256:9c32635fca3c250f5a3d2e424819419cd4a0f277c1a383b20fdd95e799d1da7c", - "sha256:9e19396065fdbbbc7c0b288a4e70694e1e63593388020fdb86076b12c315bda5", - "sha256:a9e7606233fa6c559491758cb319fab6cec25d931cdb5db670c434dde44ab56b", - "sha256:c914312ad7c923ac154821fbd591e8482ab03cdb190e14b05e30bf856f69e98c", - "sha256:d354ebb06f851f5f2cbc675bbb1369f71091aec6a894986d68341cbca59e7e56", - "sha256:d35a25989112c07a994070f1b3c711b19a14209c7608802eced3bcbf07c375bb", - "sha256:d71c128151c2d93fab36d7273b6a6696a63e0aa03ba3f7b1b0abb862c2344765", - "sha256:d77e4cbecc30f3a8406873c83075c5dae9dcd2ba1c0ffb088edd29372d3df84c", - "sha256:dd0b68d212d0992e2a906c6c34a1ef3f82b3dba74ff99744c77f390ffecb0cca", - "sha256:f0f97d3e0ab12456733687fc99d05e4de67f12d48a57c3baf1f5a1c6cd76c876", - "sha256:f7b72646a5a50aed8535d8cd2d7e915238f389c181d20143f67c2c6527ca5d0e", - "sha256:fd06663aa38b2b7b1f71017329545e17f2a583b127de4eeaabdc4cb16cf3a942" + "sha256:163d3ee445a0b4c0109877da9e46271aacf4e5e3d60ae7368669555c30f13e7c", + "sha256:1af0bfe7b0c13a0e613a27311fd4f9c5d024e8fc0f4b3d284e7df02a58a11fc0", + "sha256:2169c3a1bf52d5b30cc98625b5919a964c571a32e8646be20be6c7e3e82079de", + "sha256:218f079fa48e2ef812dc3d3ce6ec2f67ac56427ba4b038d5d6331f2cceb489c2", + "sha256:26a958930687e94c4c6c73c171e4d4783b82ae4e16aa3424e6bcd4529bceedf0", + "sha256:2c7c195aef3acdbc853942bc674844031a732890d2fee88a324298ed376b6c2b", + "sha256:2ecdbfed7004669472bfa27c8d51012c717c241c7154ae17e4c8f93024043525", + "sha256:345fc31b71a90ada1b51826537917b19a1af685a91c0f066787069c184d7d00f", + "sha256:378a06649503f548be5f1e9eec2e94cc1d6138250b82a08dcc6151bca8cec107", + "sha256:3f300bf2930e501dde09605de85cb2b84c2638e2c954be02a3c86f28176d3525", + "sha256:6c2f66c653ce8bbd7e789d0f7f92c3f9fea881b55226f0ae5ee550cce9e3cf0e", + "sha256:6fccbac2633831b877a8fbf865f7082d34895e82a015795a9f80f99a2efe2576", + "sha256:7a166f8ccb6888358d3e67795b057540ea7caa71ab9e089b0cb0097f01088965", + "sha256:8f6b84f887ec6fef6c1796779f8ec2603dc7e9ef52bc9269de719d4bcbdaebbb", + "sha256:92cf3ceb7bb90cf35b8bd993c640b15d4832ba0e142a3b9da5006ef217da595d", + "sha256:a20dfdf73f56da674926a3811929cff9fd23b9af90be9a6c36ac246a3486eef3", + "sha256:a84415df4689251556c961e4fe3b25d30e32f00faa8064ce0909458dbe0d67b2", + "sha256:ab1aa1cd50df3860f624c9713ee9e690eefd4e049d3a4d86577bab6e741e9616", + "sha256:abc9dcf85e75a8687f2a6d560c0c1a2593e8e34ba6f9ad6721f8212c5de179a2", + "sha256:c10454710a81a2f4b1ff4d1c83ac2cec63e0e55845a56324991514af5b1299d0", + "sha256:c38f80719e4dfae7a6311a4f091f07f4fb2fb5d602352015d5639f63f8fabb68", + "sha256:d75cf00605630b2cfefa5c62373c605dcda1cc0d607902847dbb8e8e9b67c1ce", + "sha256:dce15cb6ef604c9e38fdaa848f58f83153ade9f4aa5e4cf5812aa27163561750", + "sha256:e7e0db4311bb76bf3f6e0380f71912cfa6d0be7cc635e3772476050b0dabdabd", + "sha256:eac59cae78dfe3fbf7ece25c170d7a152f88df7643381aa5e7344c2028a8d8d4", + "sha256:ead7b3e1567bd14cacd44279c5e42cd19f54b9feed39180220253f4fbe3abd56", + "sha256:ed772a5e8e7e5dd6bede960a86940c17cf653c7f158dafa5d52e919b676f10ba", + "sha256:f2d73131acb94afa45de8b6b8a4bfb21bbe3736633d6478e53247f19dd8c299c" ], "index": "pypi", - "version": "==2.8" + "version": "==2.8.1" }, "pytz": { "hashes": [ - "sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9", - "sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c" + "sha256:303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", + "sha256:d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141" ], - "version": "==2018.9" + "version": "==2019.1" + }, + "requests": { + "hashes": [ + "sha256:502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", + "sha256:7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b" + ], + "index": "pypi", + "version": "==2.21.0" }, "six": { "hashes": [ @@ -163,6 +192,13 @@ ], "version": "==0.3.0" }, + "urllib3": { + "hashes": [ + "sha256:61bf29cada3fc2fbefad4fdf059ea4bd1b4a86d2b6d15e1c7c0b582b9752fe39", + "sha256:de9529817c93f27c8ccbfead6985011db27bd0ddfcdb2d86f3f663385c6a9c22" + ], + "version": "==1.24.1" + }, "uwsgi": { "hashes": [ "sha256:4972ac538800fb2d421027f49b4a1869b66048839507ccf0aa2fda792d99f583" @@ -188,32 +224,42 @@ }, "coverage": { "hashes": [ + "sha256:0c5fe441b9cfdab64719f24e9684502a59432df7570521563d7b1aff27ac755f", + "sha256:2b412abc4c7d6e019ce7c27cbc229783035eef6d5401695dccba80f481be4eb3", "sha256:3684fabf6b87a369017756b551cef29e505cb155ddb892a7a29277b978da88b9", "sha256:39e088da9b284f1bd17c750ac672103779f7954ce6125fd4382134ac8d152d74", "sha256:3c205bc11cc4fcc57b761c2da73b9b72a59f8d5ca89979afb0c1c6f9e53c7390", + "sha256:42692db854d13c6c5e9541b6ffe0fe921fe16c9c446358d642ccae1462582d3b", "sha256:465ce53a8c0f3a7950dfb836438442f833cf6663d407f37d8c52fe7b6e56d7e8", "sha256:48020e343fc40f72a442c8a1334284620f81295256a6b6ca6d8aa1350c763bbe", + "sha256:4ec30ade438d1711562f3786bea33a9da6107414aed60a5daa974d50a8c2c351", "sha256:5296fc86ab612ec12394565c500b412a43b328b3907c0d14358950d06fd83baf", "sha256:5f61bed2f7d9b6a9ab935150a6b23d7f84b8055524e7be7715b6513f3328138e", + "sha256:6899797ac384b239ce1926f3cb86ffc19996f6fa3a1efbb23cb49e0c12d8c18c", "sha256:68a43a9f9f83693ce0414d17e019daee7ab3f7113a70c79a3dd4c2f704e4d741", "sha256:6b8033d47fe22506856fe450470ccb1d8ba1ffb8463494a15cfc96392a288c09", "sha256:7ad7536066b28863e5835e8cfeaa794b7fe352d99a8cded9f43d1161be8e9fbd", "sha256:7bacb89ccf4bedb30b277e96e4cc68cd1369ca6841bde7b005191b54d3dd1034", "sha256:839dc7c36501254e14331bcb98b27002aa415e4af7ea039d9009409b9d2d5420", + "sha256:8e679d1bde5e2de4a909efb071f14b472a678b788904440779d2c449c0355b27", "sha256:8f9a95b66969cdea53ec992ecea5406c5bd99c9221f539bca1e8406b200ae98c", "sha256:932c03d2d565f75961ba1d3cec41ddde00e162c5b46d03f7423edcb807734eab", + "sha256:93f965415cc51604f571e491f280cff0f5be35895b4eb5e55b47ae90c02a497b", "sha256:988529edadc49039d205e0aa6ce049c5ccda4acb2d6c3c5c550c17e8c02c05ba", "sha256:998d7e73548fe395eeb294495a04d38942edb66d1fa61eb70418871bc621227e", "sha256:9de60893fb447d1e797f6bf08fdf0dbcda0c1e34c1b06c92bd3a363c0ea8c609", "sha256:9e80d45d0c7fcee54e22771db7f1b0b126fb4a6c0a2e5afa72f66827207ff2f2", "sha256:a545a3dfe5082dc8e8c3eb7f8a2cf4f2870902ff1860bd99b6198cfd1f9d1f49", "sha256:a5d8f29e5ec661143621a8f4de51adfb300d7a476224156a39a392254f70687b", + "sha256:a9abc8c480e103dc05d9b332c6cc9fb1586330356fc14f1aa9c0ca5745097d19", "sha256:aca06bfba4759bbdb09bf52ebb15ae20268ee1f6747417837926fae990ebc41d", "sha256:bb23b7a6fd666e551a3094ab896a57809e010059540ad20acbeec03a154224ce", "sha256:bfd1d0ae7e292105f29d7deaa9d8f2916ed8553ab9d5f39ec65bcf5deadff3f9", + "sha256:c22ab9f96cbaff05c6a84e20ec856383d27eae09e511d3e6ac4479489195861d", "sha256:c62ca0a38958f541a73cf86acdab020c2091631c137bd359c4f5bddde7b75fd4", "sha256:c709d8bda72cf4cd348ccec2a4881f2c5848fd72903c185f363d361b2737f773", "sha256:c968a6aa7e0b56ecbd28531ddf439c2ec103610d3e2bf3b75b813304f8cb7723", + "sha256:ca58eba39c68010d7e87a823f22a081b5290e3e3c64714aac3c91481d8b34d22", "sha256:df785d8cb80539d0b55fd47183264b7002077859028dfe3070cf6359bf8b2d9c", "sha256:f406628ca51e0ae90ae76ea8398677a921b36f0bd71aab2099dfed08abd0322f", "sha256:f46087bbd95ebae244a0eda01a618aff11ec7a069b15a3ef8f6b520db523dcf1", diff --git a/pydis_site/apps/home/__init__.py b/pydis_site/apps/home/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/home/admin.py b/pydis_site/apps/home/admin.py deleted file mode 100644 index 4185d360..00000000 --- a/pydis_site/apps/home/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.contrib import admin - -# Register your models here. diff --git a/pydis_site/apps/home/apps.py b/pydis_site/apps/home/apps.py deleted file mode 100644 index 90dc7137..00000000 --- a/pydis_site/apps/home/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class HomeConfig(AppConfig): - name = 'home' diff --git a/pydis_site/apps/home/migrations/__init__.py b/pydis_site/apps/home/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/home/models.py b/pydis_site/apps/home/models.py deleted file mode 100644 index 0b4331b3..00000000 --- a/pydis_site/apps/home/models.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.db import models - -# Create your models here. diff --git a/pydis_site/apps/home/templatetags/__init__.py b/pydis_site/apps/home/templatetags/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/home/templatetags/extra_filters.py b/pydis_site/apps/home/templatetags/extra_filters.py deleted file mode 100644 index edffe9ac..00000000 --- a/pydis_site/apps/home/templatetags/extra_filters.py +++ /dev/null @@ -1,8 +0,0 @@ -from django import template - -register = template.Library() - - -@register.filter -def starts_with(value: str, arg: str): - return value.startswith(arg) diff --git a/pydis_site/apps/home/tests.py b/pydis_site/apps/home/tests.py deleted file mode 100644 index 54fac6e8..00000000 --- a/pydis_site/apps/home/tests.py +++ /dev/null @@ -1,9 +0,0 @@ -from django.test import TestCase -from django_hosts.resolvers import reverse - - -class TestIndexReturns200(TestCase): - def test_index_returns_200(self): - url = reverse('index') - resp = self.client.get(url) - self.assertEqual(resp.status_code, 200) diff --git a/pydis_site/apps/home/urls.py b/pydis_site/apps/home/urls.py deleted file mode 100644 index 56525af8..00000000 --- a/pydis_site/apps/home/urls.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.contrib import admin -from django.urls import path -from django.views.generic import TemplateView - - -app_name = 'home' -urlpatterns = [ - path('', TemplateView.as_view(template_name='home/index.html'), name='home.index'), - path('admin/', admin.site.urls) -] diff --git a/pydis_site/apps/home/views.py b/pydis_site/apps/home/views.py deleted file mode 100644 index fd0e0449..00000000 --- a/pydis_site/apps/home/views.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.shortcuts import render - -# Create your views here. diff --git a/pydis_site/apps/main/__init__.py b/pydis_site/apps/main/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/main/admin.py b/pydis_site/apps/main/admin.py new file mode 100644 index 00000000..4185d360 --- /dev/null +++ b/pydis_site/apps/main/admin.py @@ -0,0 +1,3 @@ +# from django.contrib import admin + +# Register your models here. diff --git a/pydis_site/apps/main/apps.py b/pydis_site/apps/main/apps.py new file mode 100644 index 00000000..90dc7137 --- /dev/null +++ b/pydis_site/apps/main/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class HomeConfig(AppConfig): + name = 'home' diff --git a/pydis_site/apps/main/migrations/__init__.py b/pydis_site/apps/main/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/main/models.py b/pydis_site/apps/main/models.py new file mode 100644 index 00000000..0b4331b3 --- /dev/null +++ b/pydis_site/apps/main/models.py @@ -0,0 +1,3 @@ +# from django.db import models + +# Create your models here. diff --git a/pydis_site/apps/main/templatetags/__init__.py b/pydis_site/apps/main/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pydis_site/apps/main/templatetags/extra_filters.py b/pydis_site/apps/main/templatetags/extra_filters.py new file mode 100644 index 00000000..edffe9ac --- /dev/null +++ b/pydis_site/apps/main/templatetags/extra_filters.py @@ -0,0 +1,8 @@ +from django import template + +register = template.Library() + + +@register.filter +def starts_with(value: str, arg: str): + return value.startswith(arg) diff --git a/pydis_site/apps/main/tests.py b/pydis_site/apps/main/tests.py new file mode 100644 index 00000000..54fac6e8 --- /dev/null +++ b/pydis_site/apps/main/tests.py @@ -0,0 +1,9 @@ +from django.test import TestCase +from django_hosts.resolvers import reverse + + +class TestIndexReturns200(TestCase): + def test_index_returns_200(self): + url = reverse('index') + resp = self.client.get(url) + self.assertEqual(resp.status_code, 200) diff --git a/pydis_site/apps/main/urls.py b/pydis_site/apps/main/urls.py new file mode 100644 index 00000000..11142040 --- /dev/null +++ b/pydis_site/apps/main/urls.py @@ -0,0 +1,11 @@ +from django.contrib import admin +from django.urls import path + +from .views import Home + + +app_name = 'home' +urlpatterns = [ + path('', Home.as_view(), name='home.index'), + path('admin/', admin.site.urls) +] diff --git a/pydis_site/apps/main/views/__init__.py b/pydis_site/apps/main/views/__init__.py new file mode 100644 index 00000000..ab52894b --- /dev/null +++ b/pydis_site/apps/main/views/__init__.py @@ -0,0 +1,3 @@ +from .home import Home + +__all__ = ["Home"] diff --git a/pydis_site/apps/main/views/home.py b/pydis_site/apps/main/views/home.py new file mode 100644 index 00000000..8f45b912 --- /dev/null +++ b/pydis_site/apps/main/views/home.py @@ -0,0 +1,47 @@ +import requests +from django.shortcuts import render +from django.views import View + + + +class Home(View): + + projects = [ + "site", + "bot", + "snekbox", + "seasonalbot", + "django-simple-bulma", + "django-crispy-bulma", + ] + + def _get_repo_data(self): + """ + This will get language, stars and forks for the projects listed in Home.projects. + + Returns a dictionary with the data, in a template-friendly manner. The rate limit for + this particular endpoint is 30 requests per minute. This should be plenty for now, + but if we ever run into rate limiting issues, we should implement some form of caching + for this data. + """ + + # Gotta authenticate, or we get terrible rate limits. + + # We need to query the Search API https://developer.github.com/v3/search/, using a single + # query to query for all of the projects at the same time, and making sure we cache that data + # and make the request no more often than once per minute or something reasonable + # like that. + + endpoint = "https://api.github.com/search/repositories?q=" + "repo+name+separated+by+pluses" + + # And finally + + + + + + + def get(self, request): + + # Call the GitHub API and ask it for some data + return render(request, "home/index.html", {}) diff --git a/pydis_site/apps/wiki/__init__.py b/pydis_site/apps/wiki/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/wiki/admin.py b/pydis_site/apps/wiki/admin.py deleted file mode 100644 index 4185d360..00000000 --- a/pydis_site/apps/wiki/admin.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.contrib import admin - -# Register your models here. diff --git a/pydis_site/apps/wiki/apps.py b/pydis_site/apps/wiki/apps.py deleted file mode 100644 index fce4708e..00000000 --- a/pydis_site/apps/wiki/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class WikiConfig(AppConfig): - name = 'wiki' diff --git a/pydis_site/apps/wiki/migrations/__init__.py b/pydis_site/apps/wiki/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/pydis_site/apps/wiki/models.py b/pydis_site/apps/wiki/models.py deleted file mode 100644 index 0b4331b3..00000000 --- a/pydis_site/apps/wiki/models.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.db import models - -# Create your models here. diff --git a/pydis_site/apps/wiki/tests.py b/pydis_site/apps/wiki/tests.py deleted file mode 100644 index a79ca8be..00000000 --- a/pydis_site/apps/wiki/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.test import TestCase - -# Create your tests here. diff --git a/pydis_site/apps/wiki/views.py b/pydis_site/apps/wiki/views.py deleted file mode 100644 index fd0e0449..00000000 --- a/pydis_site/apps/wiki/views.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.shortcuts import render - -# Create your views here. diff --git a/pydis_site/hosts.py b/pydis_site/hosts.py index 34acfd09..9e58628c 100644 --- a/pydis_site/hosts.py +++ b/pydis_site/hosts.py @@ -3,8 +3,7 @@ from django_hosts import host, patterns host_patterns = patterns( '', - # host(r"subdomain pattern", "URLs module", "host entry name") host(r'admin', 'pydis_site.apps.admin.urls', name="admin"), host(r'api', 'pydis_site.apps.api.urls', name='api'), - host(r'.*', 'pydis_site.apps.home.urls', name=settings.DEFAULT_HOST) + host(r'.*', 'pydis_site.apps.main.urls', name=settings.DEFAULT_HOST) ) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 03ad6bc5..4a5b0523 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -63,8 +63,7 @@ else: INSTALLED_APPS = [ 'pydis_site.apps.api', - 'pydis_site.apps.home', - 'pydis_site.apps.wiki', + 'pydis_site.apps.main', 'django.contrib.admin', 'django.contrib.auth', diff --git a/pydis_site/urls.py b/pydis_site/urls.py index c68375da..e4ef058b 100644 --- a/pydis_site/urls.py +++ b/pydis_site/urls.py @@ -2,5 +2,5 @@ from django.urls import include, path urlpatterns = ( - path('', include('pydis_site.apps.home.urls', namespace='home')), + path('', include('pydis_site.apps.main.urls', namespace='home')), ) -- cgit v1.2.3 From cf1fc2870326c431d0c4dc3fe46f2ae41c2fd5aa Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Wed, 17 Apr 2019 23:57:14 +0200 Subject: The GitHub API stuff is done now, including data caching. Just a couple of minor bugfixes left before this is PR-ready. --- pydis_site/apps/main/models.py | 3 - pydis_site/apps/main/views/home.py | 119 ++++++++++++++++++++++------------ pydis_site/settings.py | 10 +++ pydis_site/static/css/home/index.css | 11 ++++ pydis_site/templates/base/navbar.html | 24 +++---- pydis_site/templates/home/index.html | 105 +++++------------------------- 6 files changed, 129 insertions(+), 143 deletions(-) delete mode 100644 pydis_site/apps/main/models.py (limited to 'pydis_site/settings.py') diff --git a/pydis_site/apps/main/models.py b/pydis_site/apps/main/models.py deleted file mode 100644 index 0b4331b3..00000000 --- a/pydis_site/apps/main/models.py +++ /dev/null @@ -1,3 +0,0 @@ -# from django.db import models - -# Create your models here. diff --git a/pydis_site/apps/main/views/home.py b/pydis_site/apps/main/views/home.py index 883177bb..f3f9d726 100644 --- a/pydis_site/apps/main/views/home.py +++ b/pydis_site/apps/main/views/home.py @@ -3,67 +3,104 @@ import requests from django.shortcuts import render from django.utils import timezone from django.views import View +from django.conf import settings from pydis_site.apps.main.models import RepoData -GITHUB_API = "https://api.github.com/repos" -REPOS = [ - "python-discord/site", - "python-discord/bot", - "python-discord/snekbox", - "python-discord/seasonalbot", - "python-discord/django-simple-bulma", - "python-discord/django-crispy-bulma", -] - -# https://api.github.com/users/python-discord/repos gets all the data in one query. +GITHUB_API = "https://api.github.com/users/python-discord/repos" class Home(View): - def _get_repo_data(self, repo_name): - """This will get language, stars and forks for the requested GitHub repo.""" - # Try to get the data from the cache + def _get_api_data(self): + """Call the GitHub API and get information about our repos.""" + repo_dict = {repo_name: {} for repo_name in settings.HOMEPAGE_REPOS} + + # Fetch the data from the GitHub API + api_data = requests.get(GITHUB_API) + api_data = api_data.json() + + # Process the API data into our dict + print(f"repo_dict = {repo_dict}") + for repo in api_data: + full_name = repo["full_name"] + + if full_name in settings.HOMEPAGE_REPOS: + repo_dict[full_name] = { + "full_name": repo["full_name"], + "description": repo["description"], + "language": repo["language"], + "forks_count": repo["forks_count"], + "stargazers_count": repo["stargazers_count"], + } + print(f"repo_dict after processing = {repo_dict}") + return repo_dict + + def _get_repo_data(self): + """Build a list of RepoData objects that we can use to populate the front page.""" + + # Try to get site data from the cache try: - repo_data = RepoData.objects.get(repo_name=repo_name) + repo_data = RepoData.objects.get(repo_name="python-discord/site") - # If the data is older than 2 minutes, we should refresh it + # If the data is older than 2 minutes, we should refresh it. THIS PROBABLY ALWAYS FAILS? if (timezone.now() - repo_data.last_updated).seconds > 120: - # Fetch the data from the GitHub API - api_data = requests.get(f"{GITHUB_API}/{repo_name}") - api_data = api_data.json() + diff = (timezone.now() - repo_data.last_updated).seconds + print(f"okay baby, it's old! the seconds difference comes to: {diff}") - # Update the current object, and save it. - repo_data.description = api_data["description"] - repo_data.language = api_data["language"] - repo_data.forks = api_data["forks_count"] - repo_data.stargazers = api_data["stargazers_count"] - repo_data.save() - return repo_data + # Get new data from API + api_data_container = self._get_api_data() + repo_data_container = [] + + # Update or create all RepoData objects in settings.HOMEPAGE_REPOS + for repo_name, api_data in api_data_container.items(): + try: + repo_data = RepoData.objects.get(repo_name=repo_name) + repo_data.description = api_data["description"] + repo_data.language = api_data["language"] + repo_data.forks = api_data["forks_count"] + repo_data.stargazers = api_data["stargazers_count"] + except RepoData.DoesNotExist: + repo_data = RepoData( + repo_name=api_data["full_name"], + description=api_data["description"], + forks=api_data["forks_count"], + stargazers=api_data["stargazers_count"], + language=api_data["language"], + ) + repo_data.save() + repo_data_container.append(repo_data) + return repo_data_container # Otherwise, if the data is fresher than 2 minutes old, we should just return it. else: - return repo_data + return list(RepoData.objects.all()) - # If this is raised, the data isn't there at all, so we'll need to create it. + # If this is raised, the database has no repodata at all, we will create them all. except RepoData.DoesNotExist: - api_data = requests.get(f"{GITHUB_API}/{repo_name}") - api_data = api_data.json() - repo_data = RepoData( - description=api_data["description"], - forks=api_data["forks_count"], - stargazers=api_data["stargazers_count"], - language=api_data["language"], - ) - repo_data.save() - return repo_data + + # Get new data from API + api_data_container = self._get_api_data() + repo_data_container = [] + + # Create all the repodata records in the database. + for repo_name, api_data in api_data_container.items(): + repo_data = RepoData( + repo_name=api_data["full_name"], + description=api_data["description"], + forks=api_data["forks_count"], + stargazers=api_data["stargazers_count"], + language=api_data["language"], + ) + repo_data.save() + repo_data_container.append(repo_data) + + return repo_data_container def get(self, request): # Collect the repo data - repo_data = [] - for repo in REPOS: - repo_data.append(self._get_repo_data(repo)) + repo_data = self._get_repo_data() # Call the GitHub API and ask it for some data return render(request, "home/index.html", {"repo_data": repo_data}) diff --git a/pydis_site/settings.py b/pydis_site/settings.py index 4a5b0523..eb21de10 100644 --- a/pydis_site/settings.py +++ b/pydis_site/settings.py @@ -258,3 +258,13 @@ BULMA_SETTINGS = { "footer-padding": "1rem 1.5rem 1rem", } } + +# Which of our GitHub repos should be displayed on the front page, and in which order? +HOMEPAGE_REPOS = [ + "python-discord/site", + "python-discord/bot", + "python-discord/snekbox", + "python-discord/seasonalbot", + "python-discord/django-simple-bulma", + "python-discord/django-crispy-bulma", +] diff --git a/pydis_site/static/css/home/index.css b/pydis_site/static/css/home/index.css index 2e201441..d1d1c01e 100644 --- a/pydis_site/static/css/home/index.css +++ b/pydis_site/static/css/home/index.css @@ -53,6 +53,17 @@ margin: 8px auto auto auto; } +div.card.github-card { + box-shadow: none; + border: #d1d5da 1px solid; + border-radius: 3px; +} + +div.repo-headline { + font-size: 1.25rem; + margin-bottom: 8px; +} + span.repo-language-dot { border-radius: 50%; height: 12px; diff --git a/pydis_site/templates/base/navbar.html b/pydis_site/templates/base/navbar.html index f9f576df..842d29d5 100644 --- a/pydis_site/templates/base/navbar.html +++ b/pydis_site/templates/base/navbar.html @@ -19,10 +19,10 @@ {# Content on the right side of the navbar #}