diff --git a/.gitignore b/.gitignore index a1b194b..e4e9202 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ led / optimized / DLL files __pycache__/ *.py[cod] *$py.class +secrets.py +static_files +.idea/ # C extensions *.so diff --git a/config/settings.py b/config/settings.py index 309be78..387beea 100644 --- a/config/settings.py +++ b/config/settings.py @@ -11,8 +11,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ """ from pathlib import Path -import os -from my_secrets import secrets +from my_secrets.secrets import * # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -21,9 +20,6 @@ BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = secrets.SECRET_KEY - # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -34,6 +30,7 @@ ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'pages', + 'notes', 'django.contrib.admin', 'django.contrib.auth', @@ -61,7 +58,7 @@ ROOT_URLCONF = 'config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [BASE_DIR / 'templates', BASE_DIR / 'notion_updater/templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -125,4 +122,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, 'static/') + +import os +STATIC_ROOT = os.path.join(BASE_DIR, 'static_files') +STATICFILES_DIRS = [BASE_DIR / "static"] \ No newline at end of file diff --git a/config/urls.py b/config/urls.py index f43975b..5ec3a6d 100644 --- a/config/urls.py +++ b/config/urls.py @@ -16,10 +16,8 @@ Including another URLconf from django.contrib import admin from django.urls import path, include -from django.conf import settings -from django.conf.urls.static import static - urlpatterns = [ path('admin/', admin.site.urls), + path('notes/', include('notes.urls')), path('', include('pages.urls')) -] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) +] diff --git a/my_secrets/definitions.py b/my_secrets/definitions.py index 67c7212..3c4e567 100644 --- a/my_secrets/definitions.py +++ b/my_secrets/definitions.py @@ -8,4 +8,6 @@ SECRET_KEYS = [ # start with your Django secret key like this: "SECRET_KEY", + "NOTION_URL", + "NOTION_COOKIE", ] diff --git a/my_secrets/secrets.py.sample.py b/my_secrets/secrets.py.sample.py new file mode 100644 index 0000000..3e6e702 --- /dev/null +++ b/my_secrets/secrets.py.sample.py @@ -0,0 +1,11 @@ +# Django +SECRET_KEY = "" # Add your django secret key + +# Notion Client +NOTION_URL = "" # Add the notion url manually +NOTION_COOKIE = "" # Follow the steps listed below + +# 1. Login to notion and navigate to the home page of your page. (Not in Guest or Incognito) +# 2. Open up developer tools by pressing Ctrl + Shift + i, and navigate to the application tab +# 3. Click on the cookie dropdown and click on the single cookie that is located there. +# 4. Copy the token_v2 info and paste it into NOTION_COOKIE diff --git a/pages/migrations/__init__.py b/notes/__init__.py similarity index 100% rename from pages/migrations/__init__.py rename to notes/__init__.py diff --git a/notes/admin.py b/notes/admin.py new file mode 100644 index 0000000..0ce7c5c --- /dev/null +++ b/notes/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from .models import NotionPage + +# Register your models here. +admin.site.register(NotionPage) \ No newline at end of file diff --git a/notes/apps.py b/notes/apps.py new file mode 100644 index 0000000..b6155ac --- /dev/null +++ b/notes/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class NotesConfig(AppConfig): + name = 'notes' diff --git a/notes/models.py b/notes/models.py new file mode 100644 index 0000000..97a1f04 --- /dev/null +++ b/notes/models.py @@ -0,0 +1,19 @@ +from django.db import models +from django.conf import settings +from notion.client import NotionClient + +client = NotionClient(token_v2=settings.NOTION_COOKIE) + + +# Create your models here. +class NotionPage(models.Model): + url = models.URLField(max_length=300) + page = None + + def __init__(self, *args, **kwargs): + super(NotionPage, self).__init__(*args, **kwargs) + if self.url: + self.page = client.get_block(self.url) + + def __str__(self): + return str(self.page and self.page.title) diff --git a/notes/static/notes/css/base.css b/notes/static/notes/css/base.css new file mode 100644 index 0000000..0c81722 --- /dev/null +++ b/notes/static/notes/css/base.css @@ -0,0 +1,4 @@ +.content { + padding: 15px; + margin: 10px; +} \ No newline at end of file diff --git a/notes/static/notes/css/meeting.css b/notes/static/notes/css/meeting.css new file mode 100644 index 0000000..1a1b82a --- /dev/null +++ b/notes/static/notes/css/meeting.css @@ -0,0 +1,30 @@ +@import url('https://fonts.googleapis.com/css2?family=Lemonada&display=swap'); +h2 { + font-size: 40px; + margin-top: 10px; + text-align: center; + font-family: 'Lemonada', cursive; +} +.BulletedListBlock { +} +.TodoBlock { + font-weight: bold; +} +.SubheaderBlock { + list-style-type: none; + padding: 0px; + margin: 0px; + font-size: 30px; + margin-top: 5px; + font-family: 'Lemonada', cursive; +} +.SubsubheaderBlock { + list-style-type: none; + padding: 0px; + margin: 0px; + font-size: 30px; + margin-top: 5px; + font-family: 'Lemonada', cursive; +} +.TextBlock { +} \ No newline at end of file diff --git a/notes/templates/notes/base.html b/notes/templates/notes/base.html new file mode 100644 index 0000000..086c05e --- /dev/null +++ b/notes/templates/notes/base.html @@ -0,0 +1,18 @@ +{% load static %} + + +
+ +