Skip to content

Commit 9fa9dc4

Browse files
committed
🎉 initial commit
0 parents  commit 9fa9dc4

33 files changed

+2767
-0
lines changed

.github/workflows/docs.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pages: write
13+
id-token: write
14+
contents: read
15+
environment:
16+
name: github-pages
17+
url: ${{ steps.deployment.outputs.page_url }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
persist-credentials: false
22+
- name: Setup uv
23+
uses: astral-sh/setup-uv@v6
24+
with:
25+
enable-cache: true
26+
python-version: "3.13"
27+
activate-environment: true
28+
- name: Install dependencies
29+
run: uv sync
30+
- run: pdoc --output-dir docs/ vue_ssr
31+
- uses: actions/upload-pages-artifact@v3
32+
with:
33+
path: docs/
34+
- uses: actions/deploy-pages@v4
35+

.github/workflows/test.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Test
2+
3+
on: push
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.13'
16+
- uses: pre-commit/[email protected]
17+
18+
test:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
python-version: ['3.13']
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup uv
26+
uses: astral-sh/setup-uv@v6
27+
with:
28+
enable-cache: true
29+
python-version: ${{ matrix.python-version }}
30+
activate-environment: true
31+
- name: Install pnpm
32+
uses: pnpm/action-setup@v4
33+
with:
34+
version: 10
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 22
39+
cache: 'pnpm'
40+
cache-dependency-path: 'test/frontend/pnpm-lock.yaml'
41+
- name: Install JS dependencies
42+
run: pnpm install
43+
working-directory: test/frontend
44+
- name: Install Python dependencies
45+
run: uv sync
46+
- name: Build frontend
47+
run: pnpm run build
48+
working-directory: test/frontend
49+
- name: Collect static files
50+
run: python manage.py collectstatic --noinput
51+
- name: Run tests
52+
run: |
53+
coverage run -m pytest
54+
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
55+
56+

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Python
2+
.venv
3+
*.egg-info
4+
5+
# Django
6+
db.sqlite3
7+
static
8+
public
9+
10+
# coverage
11+
.coverage
12+
htmlcov
13+
14+
# testing
15+
*.sock
16+
17+
# caches
18+
__pycache__
19+
20+
# IntelliJ based IDEs
21+
.idea
22+
23+
# Finder (MacOS) folder config
24+
.DS_Store
25+
26+
# Node.js
27+
dist
28+
build
29+
node_modules

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.2
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format

LICENSE

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

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include README.md
2+
include LICENSE

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Vue Server-Side Rendering in Python
2+
3+
Client for [`vue-ssr-service`](https://github.com/krmax44/vue-ssr-service). See its documentation for a [quick start guide](https://github.com/krmax44/vue-ssr-service#getting-started-with-vite).
4+
5+
## Stand-alone
6+
7+
```python
8+
from vue_ssr import ServerRenderer
9+
10+
renderer = ServerRenderer()
11+
renderer.render("myComponent", props={"name": "friend"})
12+
# "<p>Hello, friend!</p>"
13+
```
14+
15+
## With Django
16+
17+
Works well in conjunction with [`django-vite`](https://github.com/MrBin99/django-vite). Add it to your installed apps:
18+
19+
```py
20+
INSTALLED_APPS = [
21+
"vue_ssr",
22+
...
23+
]
24+
```
25+
26+
Then, you can simply use the provided template tag:
27+
28+
```django
29+
{% load vue_ssr %}
30+
<user-greeting>{% render_vue "userGreeting" name=request.user.username %}</user-greeting>
31+
```
32+
33+
Or pass a dict with props:
34+
35+
```django
36+
<my-app>{% render_vue "myApp" props=props %}</my-app>
37+
```

manage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
4+
import os
5+
import sys
6+
7+
8+
def main():
9+
"""Run administrative tasks."""
10+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")
11+
try:
12+
from django.core.management import execute_from_command_line
13+
except ImportError as exc:
14+
raise ImportError(
15+
"Couldn't import Django. Are you sure it's installed and "
16+
"available on your PYTHONPATH environment variable? Did you "
17+
"forget to activate a virtual environment?"
18+
) from exc
19+
execute_from_command_line(sys.argv)
20+
21+
22+
if __name__ == "__main__":
23+
main()

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[project]
2+
name = "vue-ssr"
3+
version = "0.1.0"
4+
description = "Render Vue components on the server side"
5+
readme = "README.md"
6+
requires-python = ">=3.10"
7+
dependencies = ["requests>=2.0.0", "requests-unixsocket>=0.4.1"]
8+
9+
[build-system]
10+
requires = ["setuptools", "setuptools-scm"]
11+
build-backend = "setuptools.build_meta"
12+
13+
[tool.setuptools]
14+
packages = ["vue_ssr"]
15+
16+
[tool.ruff.lint]
17+
extend-select = ["I001"]
18+
19+
[tool.ruff.lint.isort]
20+
section-order = [
21+
"future",
22+
"standard-library",
23+
"third-party",
24+
"first-party",
25+
"local-folder",
26+
]
27+
default-section = "third-party"
28+
29+
[tool.pytest.ini_options]
30+
DJANGO_SETTINGS_MODULE = "test.settings"
31+
python_files = ["test_*.py"]
32+
timeout = 10
33+
34+
[tool.coverage.run]
35+
source = ["vue_ssr"]
36+
omit = ["*/wsgi.py", "*/asgi.py"]
37+
branch = true
38+
39+
[dependency-groups]
40+
dev = [
41+
"coverage[toml]>=7.8.0",
42+
"django>=5.2.1",
43+
"django-vite>=3.1.0",
44+
"pdoc>=15.0.3",
45+
"pytest>=8.3.5",
46+
"pytest-django>=4.11.1",
47+
"pytest-timeout>=2.4.0",
48+
"ruff>=0.11.10",
49+
]

test/__init__.py

Whitespace-only changes.

test/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for example project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test.settings")
15+
16+
application = get_asgi_application()

0 commit comments

Comments
 (0)