From 1ed89ebb3262988ad672184c3ac5021ba30b3068 Mon Sep 17 00:00:00 2001 From: Warren Chen Date: Fri, 10 Oct 2025 13:51:49 +0900 Subject: [PATCH] reate project --- .vscode/settings.json | 0 innovedus_cms/.dockerignore | 3 + innovedus_cms/Dockerfile | 21 ++ innovedus_cms/fly.toml | 30 +++ innovedus_cms/home/__init__.py | 0 innovedus_cms/home/apps.py | 6 + innovedus_cms/home/migrations/0001_initial.py | 31 +++ .../home/migrations/0002_create_homepage.py | 66 ++++++ innovedus_cms/home/migrations/__init__.py | 0 innovedus_cms/home/models.py | 7 + .../home/static/css/welcome_page.css | 184 ++++++++++++++++ .../home/templates/home/home_page.html | 21 ++ .../home/templates/home/welcome_page.html | 52 +++++ innovedus_cms/home/tests.py | 43 ++++ innovedus_cms/manage.py | 22 ++ innovedus_cms/mysite/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin 0 -> 167 bytes innovedus_cms/mysite/settings/__init__.py | 0 .../__pycache__/__init__.cpython-313.pyc | Bin 0 -> 176 bytes .../settings/__pycache__/base.cpython-313.pyc | Bin 0 -> 4082 bytes .../settings/__pycache__/dev.cpython-313.pyc | Bin 0 -> 509 bytes innovedus_cms/mysite/settings/base.py | 199 ++++++++++++++++++ innovedus_cms/mysite/settings/dev.py | 18 ++ innovedus_cms/mysite/settings/production.py | 14 ++ innovedus_cms/mysite/static/css/mysite.css | 0 innovedus_cms/mysite/static/js/mysite.js | 0 innovedus_cms/mysite/templates/404.html | 11 + innovedus_cms/mysite/templates/500.html | 13 ++ innovedus_cms/mysite/templates/base.html | 46 ++++ innovedus_cms/mysite/urls.py | 35 +++ innovedus_cms/mysite/wsgi.py | 16 ++ innovedus_cms/requirements.txt | 5 + innovedus_cms/search/__init__.py | 0 .../search/templates/search/search.html | 38 ++++ innovedus_cms/search/views.py | 46 ++++ 35 files changed, 927 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 innovedus_cms/.dockerignore create mode 100644 innovedus_cms/Dockerfile create mode 100644 innovedus_cms/fly.toml create mode 100644 innovedus_cms/home/__init__.py create mode 100644 innovedus_cms/home/apps.py create mode 100644 innovedus_cms/home/migrations/0001_initial.py create mode 100644 innovedus_cms/home/migrations/0002_create_homepage.py create mode 100644 innovedus_cms/home/migrations/__init__.py create mode 100644 innovedus_cms/home/models.py create mode 100644 innovedus_cms/home/static/css/welcome_page.css create mode 100644 innovedus_cms/home/templates/home/home_page.html create mode 100644 innovedus_cms/home/templates/home/welcome_page.html create mode 100644 innovedus_cms/home/tests.py create mode 100644 innovedus_cms/manage.py create mode 100644 innovedus_cms/mysite/__init__.py create mode 100644 innovedus_cms/mysite/__pycache__/__init__.cpython-313.pyc create mode 100644 innovedus_cms/mysite/settings/__init__.py create mode 100644 innovedus_cms/mysite/settings/__pycache__/__init__.cpython-313.pyc create mode 100644 innovedus_cms/mysite/settings/__pycache__/base.cpython-313.pyc create mode 100644 innovedus_cms/mysite/settings/__pycache__/dev.cpython-313.pyc create mode 100644 innovedus_cms/mysite/settings/base.py create mode 100644 innovedus_cms/mysite/settings/dev.py create mode 100644 innovedus_cms/mysite/settings/production.py create mode 100644 innovedus_cms/mysite/static/css/mysite.css create mode 100644 innovedus_cms/mysite/static/js/mysite.js create mode 100644 innovedus_cms/mysite/templates/404.html create mode 100644 innovedus_cms/mysite/templates/500.html create mode 100644 innovedus_cms/mysite/templates/base.html create mode 100644 innovedus_cms/mysite/urls.py create mode 100644 innovedus_cms/mysite/wsgi.py create mode 100644 innovedus_cms/requirements.txt create mode 100644 innovedus_cms/search/__init__.py create mode 100644 innovedus_cms/search/templates/search/search.html create mode 100644 innovedus_cms/search/views.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/.dockerignore b/innovedus_cms/.dockerignore new file mode 100644 index 0000000..b7c39d7 --- /dev/null +++ b/innovedus_cms/.dockerignore @@ -0,0 +1,3 @@ +fly.toml +.git/ +*.sqlite3 diff --git a/innovedus_cms/Dockerfile b/innovedus_cms/Dockerfile new file mode 100644 index 0000000..3c36327 --- /dev/null +++ b/innovedus_cms/Dockerfile @@ -0,0 +1,21 @@ +ARG PYTHON_VERSION=3.13-slim + +FROM python:${PYTHON_VERSION} + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +RUN mkdir -p /code + +WORKDIR /code + +COPY requirements.txt /tmp/requirements.txt +RUN set -ex && \ + pip install --upgrade pip && \ + pip install -r /tmp/requirements.txt && \ + rm -rf /root/.cache/ +COPY . /code + +EXPOSE 8000 + +CMD ["gunicorn","--bind",":8000","--workers","2","mysite.wsgi"] diff --git a/innovedus_cms/fly.toml b/innovedus_cms/fly.toml new file mode 100644 index 0000000..c476aa9 --- /dev/null +++ b/innovedus_cms/fly.toml @@ -0,0 +1,30 @@ +# fly.toml app configuration file generated for innovedus-cms on 2025-10-10T11:33:32+09:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'innovedus-cms' +primary_region = 'nrt' +console_command = '/code/manage.py shell' + +[build] + +[env] + PORT = '8000' + +[http_service] + internal_port = 8000 + force_https = true + auto_stop_machines = 'stop' + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[vm]] + memory = '1gb' + cpu_kind = 'shared' + cpus = 1 + +[[statics]] + guest_path = '/code/static' + url_prefix = '/static/' diff --git a/innovedus_cms/home/__init__.py b/innovedus_cms/home/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/home/apps.py b/innovedus_cms/home/apps.py new file mode 100644 index 0000000..e7d1c7e --- /dev/null +++ b/innovedus_cms/home/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class HomeConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "home" diff --git a/innovedus_cms/home/migrations/0001_initial.py b/innovedus_cms/home/migrations/0001_initial.py new file mode 100644 index 0000000..67f201d --- /dev/null +++ b/innovedus_cms/home/migrations/0001_initial.py @@ -0,0 +1,31 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0040_page_draft_title"), + ] + + operations = [ + migrations.CreateModel( + name="HomePage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + on_delete=models.CASCADE, + parent_link=True, + auto_created=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page",), + ), + ] diff --git a/innovedus_cms/home/migrations/0002_create_homepage.py b/innovedus_cms/home/migrations/0002_create_homepage.py new file mode 100644 index 0000000..a3e918e --- /dev/null +++ b/innovedus_cms/home/migrations/0002_create_homepage.py @@ -0,0 +1,66 @@ +from django.db import migrations + + +def create_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model("contenttypes.ContentType") + Page = apps.get_model("wagtailcore.Page") + Site = apps.get_model("wagtailcore.Site") + HomePage = apps.get_model("home.HomePage") + + # Delete the default homepage (of type Page) as created by wagtailcore.0002_initial_data, + # if it exists + page_content_type = ContentType.objects.get( + model="page", app_label="wagtailcore" + ) + Page.objects.filter( + content_type=page_content_type, slug="home", depth=2 + ).delete() + + # Create content type for homepage model + homepage_content_type, __ = ContentType.objects.get_or_create( + model="homepage", app_label="home" + ) + + # Create a new homepage + homepage = HomePage.objects.create( + title="Home", + draft_title="Home", + slug="home", + content_type=homepage_content_type, + path="00010001", + depth=2, + numchild=0, + url_path="/home/", + ) + + # Create a site with the new homepage set as the root + Site.objects.create(hostname="localhost", root_page=homepage, is_default_site=True) + + +def remove_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model("contenttypes.ContentType") + HomePage = apps.get_model("home.HomePage") + + # Delete the default homepage + # Page and Site objects CASCADE + HomePage.objects.filter(slug="home", depth=2).delete() + + # Delete content type for homepage model + ContentType.objects.filter(model="homepage", app_label="home").delete() + + +class Migration(migrations.Migration): + + run_before = [ + ("wagtailcore", "0053_locale_model"), + ] + + dependencies = [ + ("home", "0001_initial"), + ] + + operations = [ + migrations.RunPython(create_homepage, remove_homepage), + ] diff --git a/innovedus_cms/home/migrations/__init__.py b/innovedus_cms/home/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/home/models.py b/innovedus_cms/home/models.py new file mode 100644 index 0000000..5076f57 --- /dev/null +++ b/innovedus_cms/home/models.py @@ -0,0 +1,7 @@ +from django.db import models + +from wagtail.models import Page + + +class HomePage(Page): + pass diff --git a/innovedus_cms/home/static/css/welcome_page.css b/innovedus_cms/home/static/css/welcome_page.css new file mode 100644 index 0000000..bad2933 --- /dev/null +++ b/innovedus_cms/home/static/css/welcome_page.css @@ -0,0 +1,184 @@ +html { + box-sizing: border-box; +} + +*, +*:before, +*:after { + box-sizing: inherit; +} + +body { + max-width: 960px; + min-height: 100vh; + margin: 0 auto; + padding: 0 15px; + color: #231f20; + font-family: 'Helvetica Neue', 'Segoe UI', Arial, sans-serif; + line-height: 1.25; +} + +a { + background-color: transparent; + color: #308282; + text-decoration: underline; +} + +a:hover { + color: #ea1b10; +} + +h1, +h2, +h3, +h4, +h5, +p, +ul { + padding: 0; + margin: 0; + font-weight: 400; +} + +svg:not(:root) { + overflow: hidden; +} + +.header { + display: flex; + justify-content: space-between; + align-items: center; + padding-top: 20px; + padding-bottom: 10px; + border-bottom: 1px solid #e6e6e6; +} + +.logo { + width: 150px; + margin-inline-end: 20px; +} + +.logo a { + display: block; +} + +.figure-logo { + max-width: 150px; + max-height: 55.1px; +} + +.release-notes { + font-size: 14px; +} + +.main { + padding: 40px 0; + margin: 0 auto; + text-align: center; +} + +.figure-space { + max-width: 265px; +} + +@keyframes pos { + 0%, 100% { + transform: rotate(-6deg); + } + 50% { + transform: rotate(6deg); + } +} + +.egg { + fill: #43b1b0; + animation: pos 3s ease infinite; + transform: translateY(50px); + transform-origin: 50% 80%; +} + +.main-text { + max-width: 400px; + margin: 5px auto; +} + +.main-text h1 { + font-size: 22px; +} + +.main-text p { + margin: 15px auto 0; +} + +.footer { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + border-top: 1px solid #e6e6e6; + padding: 10px; +} + +.option { + display: block; + padding: 10px 10px 10px 34px; + position: relative; + text-decoration: none; +} + +.option svg { + width: 24px; + height: 24px; + fill: gray; + border: 1px solid #d9d9d9; + padding: 5px; + border-radius: 100%; + top: 10px; + inset-inline-start: 0; + position: absolute; +} + +.option h2 { + font-size: 19px; + text-decoration: underline; +} + +.option p { + padding-top: 3px; + color: #231f20; + font-size: 15px; + font-weight: 300; +} + +@media (max-width: 996px) { + body { + max-width: 780px; + } +} + +@media (max-width: 767px) { + .option { + flex: 0 0 50%; + } +} + +@media (max-width: 599px) { + .main { + padding: 20px 0; + } + + .figure-space { + max-width: 200px; + } + + .footer { + display: block; + width: 300px; + margin: 0 auto; + } +} + +@media (max-width: 360px) { + .header-link { + max-width: 100px; + } +} diff --git a/innovedus_cms/home/templates/home/home_page.html b/innovedus_cms/home/templates/home/home_page.html new file mode 100644 index 0000000..db9e9b0 --- /dev/null +++ b/innovedus_cms/home/templates/home/home_page.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% load static %} + +{% block body_class %}template-homepage{% endblock %} + +{% block extra_css %} + +{% comment %} +Delete the line below if you're just getting started and want to remove the welcome screen! +{% endcomment %} + +{% endblock extra_css %} + +{% block content %} + +{% comment %} +Delete the line below if you're just getting started and want to remove the welcome screen! +{% endcomment %} +{% include 'home/welcome_page.html' %} + +{% endblock content %} diff --git a/innovedus_cms/home/templates/home/welcome_page.html b/innovedus_cms/home/templates/home/welcome_page.html new file mode 100644 index 0000000..dcacaf3 --- /dev/null +++ b/innovedus_cms/home/templates/home/welcome_page.html @@ -0,0 +1,52 @@ +{% load i18n wagtailcore_tags %} + +
+ + +
+
+
+ +
+
+

{% trans "Welcome to your new Wagtail site!" %}

+

{% trans 'Please feel free to join our community on Slack, or get started with one of the links below.' %}

+
+
+ diff --git a/innovedus_cms/home/tests.py b/innovedus_cms/home/tests.py new file mode 100644 index 0000000..94c5372 --- /dev/null +++ b/innovedus_cms/home/tests.py @@ -0,0 +1,43 @@ +from django.urls import reverse +from home.models import HomePage + +from wagtail.models import Page +from wagtail.test.utils import WagtailPageTestCase + + +class HomeSetUpTests(WagtailPageTestCase): + """ + Tests for basic page structure setup and HomePage creation. + """ + + def test_root_create(self): + root_page = Page.objects.get(pk=1) + self.assertIsNotNone(root_page) + + def test_homepage_create(self): + root_page = Page.objects.get(pk=1) + homepage = HomePage(title="Home") + root_page.add_child(instance=homepage) + self.assertTrue(HomePage.objects.filter(title="Home").exists()) + + +class HomeTests(WagtailPageTestCase): + """ + Tests for homepage functionality and rendering. + """ + + def setUp(self): + """ + Create a homepage instance for testing. + """ + root_page = Page.objects.get(pk=1) + self.homepage = HomePage(title="Home") + root_page.add_child(instance=self.homepage) + + def test_homepage_status_code(self): + response = self.client.get(reverse("home")) + self.assertEqual(response.status_code, 200) + + def test_homepage_template_used(self): + response = self.client.get(reverse("home")) + self.assertTemplateUsed(response, "home/home_page.html") diff --git a/innovedus_cms/manage.py b/innovedus_cms/manage.py new file mode 100644 index 0000000..71901b0 --- /dev/null +++ b/innovedus_cms/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings.dev") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/innovedus_cms/mysite/__init__.py b/innovedus_cms/mysite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/mysite/__pycache__/__init__.cpython-313.pyc b/innovedus_cms/mysite/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ae696e0d393dc968ff30e14cb65a9577e502b02f GIT binary patch literal 167 zcmey&%ge<81a%oNGC=fW5CH>>P{wB#AY&>+I)f&o-%5reCLr%KNa~iGvsFxJacWU< zOev6zami0E%}vcKDUQj^%gZlIO(`voPtHZ>D`Ev23$nHt#Q4a}$jDg43}gWSY4t2? literal 0 HcmV?d00001 diff --git a/innovedus_cms/mysite/settings/__init__.py b/innovedus_cms/mysite/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/mysite/settings/__pycache__/__init__.cpython-313.pyc b/innovedus_cms/mysite/settings/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db39baddc942758b639348aaf3a9356cb9aca203 GIT binary patch literal 176 zcmey&%ge<81a%oNGC=fW5CH>>P{wB#AY&>+I)f&o-%5reCLr%KNa~iqvsFxJacWU< zOev6zami0E%}vcKDUQj^%gZlIO(`voPtHZ>lIYq;;_lhPbtkwwJTx;nh&zS7{vI<%*e=C#0+Es09}VLK>z>% literal 0 HcmV?d00001 diff --git a/innovedus_cms/mysite/settings/__pycache__/base.cpython-313.pyc b/innovedus_cms/mysite/settings/__pycache__/base.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..07801cf9847b778dd123b99383f1474787f8966c GIT binary patch literal 4082 zcmbtX&2!tv6$eO)-=wJT4_h|ro;1_xOnalPf1nQ_Az^4`YEL;fuq{ffR?l4|o!Uw-4SSG(y7Y=XA}S;*lQ(mLW^lFU6xE z3W28Z1O5h&B7!f)lPHRkn4P^iiKAF0UOLy8c0Vt2%LDQTPZB7OMgbp33Hv!_KgVzI zDIXa_6J#7sk_i+flkk5EG*8{1zBfZ=lN_3^%wFWsj1%3b9yDQdW=}XN51B)AXdd44 zKa;W3qdapGB{}l}$N)MCE}^UBGMvI9oadFgXX%>q5fn{0^F-0=dXi$pP_;TuZs{c1+NP?3lWn3u z!Bs;DhqGA2L@{tJxw)NOtl5z3O0A`8Nopv>7)UNAI~0^82RfI9o5C$XuUIN|f|IHS z+FOdD>RJ;184VTesZIPbn8)FUVYKP(RH~*|snECKcu>__DXgVHVam|kYL%uOe^Y(+ zMgu3eI?ZOXsZt}UZ=J-WXf-f|Rg!$BG&`7nh%JJ*T!#K*)nZ|3n)w=f3o}2(3aK{C zspm@FP}HVS)ir~tn}QW1HRp!e1lLpo>7-`d*}|<&T%%^pp{=aD$PUGXnu+6GO>MU^ z;Kv*eWUAA`np>sXQtF`N*u=oeV-xnFvA{qBi?;L{ZdRKeYGA_rhElJq28;KzFT>dY zo0^k-`Zz*ci8(RM?HCR7%n;K`3V3L2x52BKp-qY@g<5!bqXipw9P`5n1FENL)eKz< zn%4)rEwxr_;^zv%0>#x1QH^Z@4Hm1%d*-LZ$_C~I7asL_F4WSyMxY#9x+bLU*Z&Zu zWJ^fH%7bmnLXIRYvvIqGUKlbAgDM236T0LxuMMkwS4ybi%}(9?#d}B+{970ehWXJz z)``|Wl~XiZeDjw>!pA3Z3c%T0^0B}jF@0YuWSB3LD^}hIi%d8E2JW=rV`zk2Fz$0q)T@3-V zalN5vh8Yp5s-((_+Q#Y<&!Tm>*)Wt(Q!%%h2Wu=KX?3_J8sTk>w=?zypc56-J`gSuTfG@f^%p5N z(t>7E%s|S1r$_`Y9amk#h_k1kKnCRPk(Q-R!#TUR*T;P{0CjgH~IXf1`Aw@RNeAKXC;%Ycz(=FurgDn)+L2ODza88-jmX0tCv{tj))|C70(q=Sy;$>gOCu_Uo*saPz_ z>!p0USXg1cC%US!P+3}C%Zp_RvBU<-<}6e`mlmzgWTUkwGPIN(tPGQl`JvUf)H(}g z#Ik7FL~K@EFW;5dM1(eqrHuSg%;#XU2%R3wi-qjEn3d#oF(ZMc+^Qr$E*2yfTnBG+ zpL||merr{J%w`8?*fG>56%3+i6b2_$DjBm5iI-W((T3OrL|D$HS8{m?$t$@+MgnUI zH`AUkkv>PZqGsU%0ntNFq)bli^F#f$#SS8H8{9=~!3s}aU&|N8jJzs7k_+prccc>7 zlJXhE#x}%kSz6Qj8?2qqDsd3?5U`lra!~A4wb7dIz;uWw&Hv!R;&sY+S@Gn z1$^^#n)pj{4|H39H_;<__PjjLzwv~5-_bnBhY#b4-TF>_SKrb1Hh--DQ2$Z?LI3mS zPxV*zpY&JyUm6EO_Tb#zgLtkRc^!%E-rBjf`_;}@d%rq}EOvu$$7jYp-T2#^p}40T z?oD%vg>JML*XB-h@AH?B4&nmjFE-N+AI3&^H+D95D?63FYcI10v5&jq*U>46J<5f~ z_b0vv9SJ)wAnsWT{cl2nsHYo*^j=up=N5WlZfaql8-w>q{B>|_e`2|h@%rY$_;fG9 V%|Q~U-bT6kD*rcbn%srM|1S;W`hoxe literal 0 HcmV?d00001 diff --git a/innovedus_cms/mysite/settings/__pycache__/dev.cpython-313.pyc b/innovedus_cms/mysite/settings/__pycache__/dev.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..11731f0370ea4be404b9d214b7c8ee8920c6c3fe GIT binary patch literal 509 zcmZ8dO=}ZT6umF=ktRAtDvB#pLBz3Sth8VwR-0r7t%)skQbZUWrZX?ev@`F;_hwSk zh2$r6qf7VxBYmg{ZgdyOMqK%Z=*F|S_nvdP=fasAMinI941Wy2B7pA&`3LpyFt_FK z7F=*q2kw_v!7VZ5Dy-zHcM(%ujj7icTdmj*^c&#mWe602Rj5hchi#<>ePot@${%1N zf$sFqTG4Sp2DBa%j>DYc`swTA^=NP_xLGHDJs&kT@~wNDn`5&<*VeY<_2Dq@Ptu*O z+l}$*YiB^>QTV4&}^r5 z_(W7)r+wh`{EqWd7|m{X|Ak}wPxsxPD-7p(bGPfan(dCWXA3Q%VUUOmyXlCs%wdeO z4=^uc63^NXyhDx|_i|Z1n}&IcNyfdH5IV+D&iyd`pQRHXXV~L7%VIL%UWCWiXd;## zrZmbE{D>_}>moA#SeBWB5c&+4XF61jsV3X<0h(52U%7IwO^t7tcBaNmS5W1PdhOT8 e^2!_#s(ezHio?opeo=ayYggf&UQ^zqn(_w>Zjjyp literal 0 HcmV?d00001 diff --git a/innovedus_cms/mysite/settings/base.py b/innovedus_cms/mysite/settings/base.py new file mode 100644 index 0000000..e5e3c5c --- /dev/null +++ b/innovedus_cms/mysite/settings/base.py @@ -0,0 +1,199 @@ +""" +Django settings for mysite project. + +Generated by 'django-admin startproject' using Django 5.2.7. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.2/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os + +PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +BASE_DIR = os.path.dirname(PROJECT_DIR) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/ + + +# Application definition + +INSTALLED_APPS = [ + "home", + "search", + "wagtail.contrib.forms", + "wagtail.contrib.redirects", + "wagtail.embeds", + "wagtail.sites", + "wagtail.users", + "wagtail.snippets", + "wagtail.documents", + "wagtail.images", + "wagtail.search", + "wagtail.admin", + "wagtail", + "modelcluster", + "taggit", + "django_filters", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "wagtail.contrib.redirects.middleware.RedirectMiddleware", +] + +ROOT_URLCONF = "mysite.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [ + os.path.join(PROJECT_DIR, "templates"), + ], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + ], + }, + }, +] + +WSGI_APPLICATION = "mysite.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/5.2/ref/settings/#databases + +import dj_database_url + +DATABASES = { + 'default': dj_database_url.config() +} + +# DATABASES = { +# "default": { +# "ENGINE": "django.db.backends.sqlite3", +# "NAME": os.path.join(BASE_DIR, "db.sqlite3"), +# } +# } + + +# Password validation +# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.2/topics/i18n/ + +LANGUAGE_CODE = "zh-hant" + +TIME_ZONE = "Asia/Taipei" + +USE_I18N = True + +USE_TZ = True + +from django.utils.translation import gettext_lazy as _ + +LANGUAGES = [ + ('en', _('English')), + ('zh-hant', _('Traditional Chinese')) +] + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.2/howto/static-files/ + +STATICFILES_FINDERS = [ + "django.contrib.staticfiles.finders.FileSystemFinder", + "django.contrib.staticfiles.finders.AppDirectoriesFinder", +] + +STATICFILES_DIRS = [ + os.path.join(PROJECT_DIR, "static"), +] + +STATIC_ROOT = os.path.join(BASE_DIR, "static") +STATIC_URL = "/static/" + +MEDIA_ROOT = os.path.join(BASE_DIR, "media") +MEDIA_URL = "/media/" + +# Default storage settings +# See https://docs.djangoproject.com/en/5.2/ref/settings/#std-setting-STORAGES +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", + }, +} + +# Django sets a maximum of 1000 fields per form by default, but particularly complex page models +# can exceed this limit within Wagtail's page editor. +DATA_UPLOAD_MAX_NUMBER_FIELDS = 10_000 + + +# Wagtail settings + +WAGTAIL_SITE_NAME = "mysite" + +# Search +# https://docs.wagtail.org/en/stable/topics/search/backends.html +WAGTAILSEARCH_BACKENDS = { + "default": { + "BACKEND": "wagtail.search.backends.database", + } +} + +# Base URL to use when referring to full URLs within the Wagtail admin backend - +# e.g. in notification emails. Don't include '/admin' or a trailing slash +WAGTAILADMIN_BASE_URL = "http://example.com" + +# Allowed file extensions for documents in the document library. +# This can be omitted to allow all files, but note that this may present a security risk +# if untrusted users are allowed to upload files - +# see https://docs.wagtail.org/en/stable/advanced_topics/deploying.html#user-uploaded-files +WAGTAILDOCS_EXTENSIONS = ['csv', 'docx', 'key', 'odt', 'pdf', 'pptx', 'rtf', 'txt', 'xlsx', 'zip'] + +CSRF_TRUSTED_ORIGINS = [ + 'https://innovedus-cms.fly.dev', +] + +ALLOWED_HOSTS = ['innovedus-cms.fly.dev'] \ No newline at end of file diff --git a/innovedus_cms/mysite/settings/dev.py b/innovedus_cms/mysite/settings/dev.py new file mode 100644 index 0000000..2a0b088 --- /dev/null +++ b/innovedus_cms/mysite/settings/dev.py @@ -0,0 +1,18 @@ +from .base import * + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-wqj0dg&a$-n_-up93u8144v)9o++=i0hhufym@8(9vwyk^p3)_" + +# SECURITY WARNING: define the correct hosts in production! +ALLOWED_HOSTS = ["*"] + +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + + +try: + from .local import * +except ImportError: + pass diff --git a/innovedus_cms/mysite/settings/production.py b/innovedus_cms/mysite/settings/production.py new file mode 100644 index 0000000..efc862f --- /dev/null +++ b/innovedus_cms/mysite/settings/production.py @@ -0,0 +1,14 @@ +from .base import * + +DEBUG = False + +# ManifestStaticFilesStorage is recommended in production, to prevent +# outdated JavaScript / CSS assets being served from cache +# (e.g. after a Wagtail upgrade). +# See https://docs.djangoproject.com/en/5.2/ref/contrib/staticfiles/#manifeststaticfilesstorage +STORAGES["staticfiles"]["BACKEND"] = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" + +try: + from .local import * +except ImportError: + pass diff --git a/innovedus_cms/mysite/static/css/mysite.css b/innovedus_cms/mysite/static/css/mysite.css new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/mysite/static/js/mysite.js b/innovedus_cms/mysite/static/js/mysite.js new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/mysite/templates/404.html b/innovedus_cms/mysite/templates/404.html new file mode 100644 index 0000000..f19ab95 --- /dev/null +++ b/innovedus_cms/mysite/templates/404.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block title %}Page not found{% endblock %} + +{% block body_class %}template-404{% endblock %} + +{% block content %} +

Page not found

+ +

Sorry, this page could not be found.

+{% endblock %} diff --git a/innovedus_cms/mysite/templates/500.html b/innovedus_cms/mysite/templates/500.html new file mode 100644 index 0000000..77379e5 --- /dev/null +++ b/innovedus_cms/mysite/templates/500.html @@ -0,0 +1,13 @@ + + + + + Internal server error + + + +

Internal server error

+ +

Sorry, there seems to be an error. Please try again soon.

+ + diff --git a/innovedus_cms/mysite/templates/base.html b/innovedus_cms/mysite/templates/base.html new file mode 100644 index 0000000..79e2a17 --- /dev/null +++ b/innovedus_cms/mysite/templates/base.html @@ -0,0 +1,46 @@ +{% load static wagtailcore_tags wagtailuserbar %} + + + + + + + {% block title %} + {% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %} + {% endblock %} + {% block title_suffix %} + {% wagtail_site as current_site %} + {% if current_site and current_site.site_name %}- {{ current_site.site_name }}{% endif %} + {% endblock %} + + {% if page.search_description %} + + {% endif %} + + + {# Force all links in the live preview panel to be opened in a new tab #} + {% if request.in_preview_panel %} + + {% endif %} + + {# Global stylesheets #} + + + {% block extra_css %} + {# Override this in templates to add extra stylesheets #} + {% endblock %} + + + + {% wagtailuserbar %} + + {% block content %}{% endblock %} + + {# Global javascript #} + + + {% block extra_js %} + {# Override this in templates to add extra javascript #} + {% endblock %} + + diff --git a/innovedus_cms/mysite/urls.py b/innovedus_cms/mysite/urls.py new file mode 100644 index 0000000..c2e8a0c --- /dev/null +++ b/innovedus_cms/mysite/urls.py @@ -0,0 +1,35 @@ +from django.conf import settings +from django.urls import include, path +from django.contrib import admin + +from wagtail.admin import urls as wagtailadmin_urls +from wagtail import urls as wagtail_urls +from wagtail.documents import urls as wagtaildocs_urls + +from search import views as search_views + +urlpatterns = [ + path("django-admin/", admin.site.urls), + path("admin/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), + path("search/", search_views.search, name="search"), +] + + +if settings.DEBUG: + from django.conf.urls.static import static + from django.contrib.staticfiles.urls import staticfiles_urlpatterns + + # Serve static and media files from development server + urlpatterns += staticfiles_urlpatterns() + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +urlpatterns = urlpatterns + [ + # For anything not caught by a more specific rule above, hand over to + # Wagtail's page serving mechanism. This should be the last pattern in + # the list: + path("", include(wagtail_urls)), + # Alternatively, if you want Wagtail pages to be served from a subpath + # of your site, rather than the site root: + # path("pages/", include(wagtail_urls)), +] diff --git a/innovedus_cms/mysite/wsgi.py b/innovedus_cms/mysite/wsgi.py new file mode 100644 index 0000000..5bdd7d4 --- /dev/null +++ b/innovedus_cms/mysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mysite project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings.dev") + +application = get_wsgi_application() diff --git a/innovedus_cms/requirements.txt b/innovedus_cms/requirements.txt new file mode 100644 index 0000000..729b367 --- /dev/null +++ b/innovedus_cms/requirements.txt @@ -0,0 +1,5 @@ +Django>=5.2,<5.3 +wagtail>=7.1,<7.2 +gunicorn +dj-database-url +psycopg[binary] \ No newline at end of file diff --git a/innovedus_cms/search/__init__.py b/innovedus_cms/search/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/innovedus_cms/search/templates/search/search.html b/innovedus_cms/search/templates/search/search.html new file mode 100644 index 0000000..476427f --- /dev/null +++ b/innovedus_cms/search/templates/search/search.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} + +{% block body_class %}template-searchresults{% endblock %} + +{% block title %}Search{% endblock %} + +{% block content %} +

Search

+ +
+ + +
+ +{% if search_results %} +
    + {% for result in search_results %} +
  • +

    {{ result }}

    + {% if result.search_description %} + {{ result.search_description }} + {% endif %} +
  • + {% endfor %} +
+ +{% if search_results.has_previous %} +Previous +{% endif %} + +{% if search_results.has_next %} +Next +{% endif %} +{% elif search_query %} +No results found +{% endif %} +{% endblock %} diff --git a/innovedus_cms/search/views.py b/innovedus_cms/search/views.py new file mode 100644 index 0000000..678bb7e --- /dev/null +++ b/innovedus_cms/search/views.py @@ -0,0 +1,46 @@ +from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator +from django.template.response import TemplateResponse + +from wagtail.models import Page + +# To enable logging of search queries for use with the "Promoted search results" module +# +# uncomment the following line and the lines indicated in the search function +# (after adding wagtail.contrib.search_promotions to INSTALLED_APPS): + +# from wagtail.contrib.search_promotions.models import Query + + +def search(request): + search_query = request.GET.get("query", None) + page = request.GET.get("page", 1) + + # Search + if search_query: + search_results = Page.objects.live().search(search_query) + + # To log this query for use with the "Promoted search results" module: + + # query = Query.get(search_query) + # query.add_hit() + + else: + search_results = Page.objects.none() + + # Pagination + paginator = Paginator(search_results, 10) + try: + search_results = paginator.page(page) + except PageNotAnInteger: + search_results = paginator.page(1) + except EmptyPage: + search_results = paginator.page(paginator.num_pages) + + return TemplateResponse( + request, + "search/search.html", + { + "search_query": search_query, + "search_results": search_results, + }, + )