Skip to content

Commit b85cce9

Browse files
authored
Merge pull request #111 from 5haiqin/main-616
Add Django Docs Clone - A Beginner-Friendly Web-Doc
2 parents c35839d + 0da9db2 commit b85cce9

File tree

16 files changed

+930
-0
lines changed

16 files changed

+930
-0
lines changed

Django-Doc_app/.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
*.manifest
29+
*.spec
30+
31+
# Installer logs
32+
pip-log.txt
33+
pip-delete-this-directory.txt
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.tox/
38+
.nox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*.cover
45+
*.py,cover
46+
.hypothesis/
47+
.pytest_cache/
48+
.mypy_cache/
49+
50+
# Django stuff:
51+
*.log
52+
local_settings.py
53+
media
54+
staticfiles
55+
56+
# SQLite database (unused by this project, but ignore anyway)
57+
db.sqlite3
58+
59+
# Environments
60+
.venv/
61+
venv/
62+
env/
63+
ENV/
64+
65+
# IDE/editor
66+
.vscode/
67+
.idea/
68+
*.iml
69+
70+
# OS files
71+
.DS_Store
72+
Thumbs.db

Django-Doc_app/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 The django_google_doc_clone Authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Django-Doc_app/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Simple Docs Clone — Django Beginner Project
2+
3+
A beginner-friendly Django project that serves a single-page, offline-capable text editor similar to Google Docs. The editor is powered by Quill.js and saves everything to your browser's localStorage. No database is used for documents.
4+
5+
## Features
6+
- Rich-text editor (bold, italic, underline, strikethrough, headings, size, color, lists, blockquote, code, links, images, undo/redo)
7+
- Editable document title
8+
- Autosave to localStorage every 5 seconds and on blur/unload
9+
- File operations: New, Import (HTML/JSON), Save HTML, Export Markdown, Export PDF, Clear Local Data
10+
- Live word and character count
11+
- Responsive, clean UI similar to Google Docs
12+
- Light/Dark theme with persistence
13+
- Optional version snapshots (keeps 3 previous saves) with restore
14+
15+
## Tech Stack
16+
- Python 3.11
17+
- Django 4.2
18+
- SQLite (default, unused)
19+
- HTML5, CSS3, JavaScript (ES6)
20+
- Frontend via CDN: Quill.js, Turndown.js, html2pdf.js, FontAwesome, Google Fonts (Inter)
21+
22+
## Project Structure
23+
```
24+
django_google_doc_clone/
25+
├─ manage.py
26+
├─ requirements.txt
27+
├─ README.md
28+
├─ LICENSE
29+
├─ django_google_doc_clone/
30+
│ ├─ __init__.py
31+
│ ├─ settings.py
32+
│ ├─ urls.py
33+
│ ├─ wsgi.py
34+
│ └─ asgi.py
35+
└─ editor/
36+
├─ __init__.py
37+
├─ views.py
38+
├─ urls.py
39+
├─ templates/
40+
│ └─ editor/
41+
│ └─ index.html
42+
└─ static/
43+
└─ editor/
44+
├─ css/
45+
│ └─ styles.css
46+
├─ js/
47+
│ └─ app.js
48+
└─ favicon.svg
49+
```
50+
51+
## Setup
52+
53+
Linux/macOS (bash):
54+
```
55+
python -m venv .venv && source .venv/bin/activate
56+
pip install -r requirements.txt
57+
python manage.py runserver
58+
```
59+
60+
Windows (PowerShell):
61+
```
62+
python -m venv .venv
63+
.\.venv\Scripts\Activate.ps1
64+
pip install -r requirements.txt
65+
python manage.py runserver
66+
```
67+
68+
Open the app at: http://127.0.0.1:8000/
69+
70+
## Using the Editor
71+
- Title: Click the title at the top to edit.
72+
- Toolbar: Use the toolbar for formatting (bold, italic, etc.).
73+
- Autosave: Content and title autosave every 5 seconds and on leaving the page.
74+
- New: Clears the current document (keeps theme and snapshots).
75+
- Import: Load an HTML or JSON file. JSON can be a raw Quill Delta or an object with `{ delta, title }`.
76+
- Save HTML: Downloads a self-contained HTML file with embedded styles.
77+
- Export Markdown: Converts the current document to .md using Turndown.
78+
- Export PDF: Creates a PDF via html2pdf.js.
79+
- Clear Local Data: Removes saved content, title, and snapshots from localStorage.
80+
- Versions: Keeps the last 3 autosave snapshots. Select one and Restore.
81+
82+
## Deployment
83+
- Render or PythonAnywhere: Deploy this Django app as usual. Since all logic is client-side, no DB setup is required beyond Django defaults.
84+
- GitHub Pages: The editor is a static page at `editor/templates/editor/index.html` using static assets at `editor/static/editor/`. You can host it as a pure static site by copying `index.html` and the `static/editor` folder to a static hosting location and replacing `{% load static %}` and `{% static ... %}` with plain relative paths.
85+
86+
## Contributing
87+
Contributions are welcome! Please fork the repo, create a feature branch, and open a pull request. Beginner-friendly issues are encouraged for Hacktoberfest.
88+
89+
## License
90+
MIT License — see LICENSE for details.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""ASGI config for django_google_doc_clone project."""
2+
3+
import os
4+
from django.core.asgi import get_asgi_application
5+
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_google_doc_clone.settings")
7+
8+
application = get_asgi_application()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from pathlib import Path
2+
3+
# Base directory
4+
BASE_DIR = Path(__file__).resolve().parent.parent
5+
6+
# SECURITY WARNING: keep the secret key used in production secret!
7+
SECRET_KEY = "django-insecure-change-me"
8+
9+
# SECURITY WARNING: don't run with debug turned on in production!
10+
DEBUG = True
11+
12+
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
13+
14+
# Application definition
15+
INSTALLED_APPS = [
16+
"django.contrib.staticfiles",
17+
"editor",
18+
]
19+
20+
MIDDLEWARE = [
21+
"django.middleware.security.SecurityMiddleware",
22+
"django.middleware.common.CommonMiddleware",
23+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
24+
]
25+
26+
ROOT_URLCONF = "django_google_doc_clone.urls"
27+
28+
TEMPLATES = [
29+
{
30+
"BACKEND": "django.template.backends.django.DjangoTemplates",
31+
"DIRS": [BASE_DIR / "django_google_doc_clone" / "templates"],
32+
"APP_DIRS": True,
33+
"OPTIONS": {
34+
"context_processors": [
35+
"django.template.context_processors.debug",
36+
"django.template.context_processors.request",
37+
"django.template.context_processors.static",
38+
],
39+
},
40+
},
41+
]
42+
43+
WSGI_APPLICATION = "django_google_doc_clone.wsgi.application"
44+
ASGI_APPLICATION = "django_google_doc_clone.asgi.application"
45+
46+
# Database (unused by this project beyond Django defaults)
47+
DATABASES = {
48+
"default": {
49+
"ENGINE": "django.db.backends.sqlite3",
50+
"NAME": BASE_DIR / "db.sqlite3",
51+
}
52+
}
53+
54+
# Internationalization
55+
LANGUAGE_CODE = "en-us"
56+
TIME_ZONE = "UTC"
57+
USE_I18N = True
58+
USE_TZ = True
59+
60+
# Static files (CSS, JavaScript, Images)
61+
STATIC_URL = "/static/"
62+
63+
# Default primary key field type
64+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Page not found · Simple Docs</title>
7+
<style>
8+
:root { --bg: #0b1320; --card:#111827; --text:#e5e7eb; --muted:#9ca3af; --accent:#3b82f6; }
9+
html, body { height: 100%; }
10+
body { margin:0; display:grid; place-items:center; background:var(--bg); color:var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif; }
11+
.card { background: var(--card); padding: 2rem 2.5rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); text-align:center; }
12+
a { color: var(--accent); text-decoration: none; font-weight: 600; }
13+
h1 { margin: 0 0 .5rem; font-size: 1.6rem; }
14+
p { margin: 0 0 1.25rem; color: var(--muted); }
15+
.btn { display:inline-block; background: var(--accent); color:white; padding:.6rem 1.1rem; border-radius:8px; }
16+
</style>
17+
</head>
18+
<body>
19+
<div class="card">
20+
<h1>404 · Page not found</h1>
21+
<p>The page you requested does not exist.</p>
22+
<a class="btn" href="/editor/">Go to the Editor</a>
23+
</div>
24+
</body>
25+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.urls import path, include
2+
from django.views.generic import RedirectView
3+
4+
urlpatterns = [
5+
path("", RedirectView.as_view(url="/editor/", permanent=False), name="root-redirect"),
6+
path("editor/", include("editor.urls")),
7+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""WSGI config for django_google_doc_clone project."""
2+
3+
import os
4+
from django.core.wsgi import get_wsgi_application
5+
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_google_doc_clone.settings")
7+
8+
application = get_wsgi_application()

0 commit comments

Comments
 (0)