diff --git a/src/snek/docs/app.py b/src/snek/docs/app.py deleted file mode 100644 index 50a4245..0000000 --- a/src/snek/docs/app.py +++ /dev/null @@ -1,43 +0,0 @@ -import pathlib - -from aiohttp import web -from app.app import Application as BaseApplication - -from snek.system.markdown import MarkdownExtension - - -class Application(BaseApplication): - - def __init__(self, path=None, *args, **kwargs): - self.path = pathlib.Path(path) - template_path = self.path - - super().__init__(template_path=template_path, *args, **kwargs) - self.jinja2_env.add_extension(MarkdownExtension) - - self.router.add_get("/{tail:.*}", self.handle_document) - - async def handle_document(self, request): - relative_path = request.match_info["tail"].strip("/") - if relative_path == "": - relative_path = "index.html" - document_path = self.path.joinpath(relative_path) - if not document_path.exists(): - return web.Response( - status=404, - body=b"Resource is not found on this server.", - content_type="text/plain", - ) - if document_path.is_dir(): - document_path = document_path.joinpath("index.html") - if not document_path.exists(): - return web.Response( - status=404, - body=b"Resource is not found on this server.", - content_type="text/plain", - ) - - response = await self.render_template( - str(document_path.relative_to(self.path)), request - ) - return response diff --git a/src/snek/docs/docs/api.html b/src/snek/docs/docs/api.html deleted file mode 100644 index e30a99d..0000000 --- a/src/snek/docs/docs/api.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends "docs/base.html" %} - -{% block main %} -{% markdown %} - -# API Documentation - -Currently only some details about the internal API are available. - -## How to create a user -```python -# Save user to the table named 'user' -# Password gets sha256 encrypted with default a salt string -# of the snek.system.security module. - -new_user_object = await app.service.user.register( - username="retoor", - password="retoorded" -) -``` - -## Encrypt string -```python -from snek.system import security - -# Support for both utf and bytes. -var1 = security.encrypt("data") -var2 = security.encrypt(b"data") - -# Is correct: -assert(var1 == var2) -``` - -## How to create a basic HTML / Markdown view -```python -from snek.system.view import BaseView - -class IndexView(BaseView): - - async def get(self): - # The render function supports markdown. - # It will render with syntax highlighting. - # Just use the .md file extension in the file name. - return await self.render("index.html") -``` -## How to create a FormView -```python -from snek.system.view import BaseFormView -from snek.form.register import RegisterForm - -class RegisterFormView(BaseFormView): - - form = RegisterForm -``` -## How to register a class view -```python -app.routes.add_view("/your-page.html", YourViewClass) -``` - -{% endmarkdown %} -{% endblock %} \ No newline at end of file diff --git a/src/snek/docs/docs/base.html b/src/snek/docs/docs/base.html deleted file mode 100644 index 7c53bec..0000000 --- a/src/snek/docs/docs/base.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - -
-
- Snek - Docs -
-
- {% block main %} - {% endblock %} -
-
- - - - \ No newline at end of file diff --git a/src/snek/docs/docs/form_api_javascript.html b/src/snek/docs/docs/form_api_javascript.html deleted file mode 100644 index c83ee7f..0000000 --- a/src/snek/docs/docs/form_api_javascript.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "docs/base.html" %} - -{% block main %} -{% markdown %} -# Form API Javascript - -## Dependencies - - generic-form.js - -## Usage -It's just a HTML component that can be declared using an one liner. Buttons and title are specified server side. -```html - -``` - -{% endmarkdown %} -{% endblock %} \ No newline at end of file diff --git a/src/snek/docs/docs/form_api_python.html b/src/snek/docs/docs/form_api_python.html deleted file mode 100644 index d7e67bc..0000000 --- a/src/snek/docs/docs/form_api_python.html +++ /dev/null @@ -1,92 +0,0 @@ -{% extends "docs/base.html" %} - -{% block main %} -{% markdown %} -# Form API Javascript - -## Dependencies - - `snek.system.form.Form` - - `snek.system.form.HTMLElement` - - `snek.system.form.FormInputElement` - - `snek.system.form.FormButtonElement` - -## Usage -Here is an example with custom validation. -This example contains a field that checks if user already exists. -If invalid, it adds an error message which automatically invalidates the field. -Handling of the error messages will automatically done client side. - -Forms are usaly located in `snek/form/[form name].py`. - -```python -from snek.system.form import Form, HTMLElement,FormInputElement,FormButtonElement - -class UsernameField(FormInputElement): - - @property - async def errors(self): - result = await super().errors - if self.value and await self.app.services.user.count(username=self.value): - result.append("Username is not available.") - return result - -class RegisterForm(Form): - - title = HTMLElement(tag="h1", text="Register") - - username = UsernameField( - name="username", - required=True, - min_length=2, - max_length=20, - regex=r"^[a-zA-Z0-9_]+$", - place_holder="Username", - type="text" - ) - email = FormInputElement( - name="email", - required=False, - regex=r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$", - place_holder="Email address", - type="email" - ) - password = FormInputElement( - name="password", - required=True, - regex=r"^[a-zA-Z0-9_.+-]{6,}", - type="password", - place_holder="Password" - ) - action = FormButtonElement( - name="action", - value="submit", - text="Register", - type="button" - ) -``` - -## Set data - -```python -# The input structure is in same format as output structure. -# Output structure is the result of await form.to_json() -data = dict( - username=dict(value="retoor"), - password=dict(value="retoorded") -) -form.set_user_data(data) - -# Check if form is valid. -is_valid = await form.is_valid - -# Convert form to a record (kv pairs) to be used for persistance. -# It does contain an filled uid (UUID4) field already to be used as primary key. -# Default fields: -# - uid (automatically generated, it's an UUID4 wich you can use as private key for database) -# - created_at (automatically generated, it's a string representation of UTC locale) -# - updated_at (execute await form.updated_at.update() before saving to set value) -key_value_values = await form.record -``` - -{% endmarkdown %} -{% endblock %} \ No newline at end of file diff --git a/src/snek/docs/docs/index.html b/src/snek/docs/docs/index.html deleted file mode 100644 index 8ced8ab..0000000 --- a/src/snek/docs/docs/index.html +++ /dev/null @@ -1,37 +0,0 @@ -{% extends "docs/base.html" %} - -{% block main %} -{% markdown %} -# Snek - -# Introduction - -Snek is a high customizable chat application. -It is made because Rocket Chat didn't fit my needs anymore. It became bloathed and very heavy commercialized. You would get upsell messages on your locally hosted instance! - -This documentation is under construction. Only the form API and the small introduction is a bit documented. - -## Quick API notes -[Small introduction / cheatsheet](/docs/docs/api.html) - -## View API -With the view classes of Snek you can render HTML and Markdown - - [API Python](#) - - [API Javascript](#) - -## ORM API -Snek's database model is based on Python dataset library. -Snek uses a model/mapper architecture build on top of that library. - - [API](#) - -## Form API -Snek does have his own components for creating and rendering forms. -All forms are made server side and client side is generated client side using a HTML component. -It's client side only one line to include a form that can validate and submit. -Validation is server side using REST. Page won't refresh. -[API Python](/docs/docs/form_api_python.html) -[API Javascript](/docs/docs/form_api_javascript.html) - - -{% endmarkdown %} -{% endblock %} \ No newline at end of file diff --git a/src/snek/app.py b/src/snekbak/app.py similarity index 100% rename from src/snek/app.py rename to src/snekbak/app.py diff --git a/src/snek/form/__init__.py b/src/snekbak/form/__init__.py similarity index 100% rename from src/snek/form/__init__.py rename to src/snekbak/form/__init__.py diff --git a/src/snek/form/login.py b/src/snekbak/form/login.py similarity index 100% rename from src/snek/form/login.py rename to src/snekbak/form/login.py diff --git a/src/snek/form/register.py b/src/snekbak/form/register.py similarity index 100% rename from src/snek/form/register.py rename to src/snekbak/form/register.py diff --git a/src/snek/gunicorn.py b/src/snekbak/gunicorn.py similarity index 100% rename from src/snek/gunicorn.py rename to src/snekbak/gunicorn.py diff --git a/src/snek/mapper/__init__.py b/src/snekbak/mapper/__init__.py similarity index 100% rename from src/snek/mapper/__init__.py rename to src/snekbak/mapper/__init__.py diff --git a/src/snek/mapper/channel.py b/src/snekbak/mapper/channel.py similarity index 100% rename from src/snek/mapper/channel.py rename to src/snekbak/mapper/channel.py diff --git a/src/snek/mapper/channel_member.py b/src/snekbak/mapper/channel_member.py similarity index 100% rename from src/snek/mapper/channel_member.py rename to src/snekbak/mapper/channel_member.py diff --git a/src/snek/mapper/channel_message.py b/src/snekbak/mapper/channel_message.py similarity index 100% rename from src/snek/mapper/channel_message.py rename to src/snekbak/mapper/channel_message.py diff --git a/src/snek/mapper/notification.py b/src/snekbak/mapper/notification.py similarity index 100% rename from src/snek/mapper/notification.py rename to src/snekbak/mapper/notification.py diff --git a/src/snek/mapper/user.py b/src/snekbak/mapper/user.py similarity index 100% rename from src/snek/mapper/user.py rename to src/snekbak/mapper/user.py diff --git a/src/snek/model/__init__.py b/src/snekbak/model/__init__.py similarity index 100% rename from src/snek/model/__init__.py rename to src/snekbak/model/__init__.py diff --git a/src/snek/model/channel.py b/src/snekbak/model/channel.py similarity index 100% rename from src/snek/model/channel.py rename to src/snekbak/model/channel.py diff --git a/src/snek/model/channel_member.py b/src/snekbak/model/channel_member.py similarity index 100% rename from src/snek/model/channel_member.py rename to src/snekbak/model/channel_member.py diff --git a/src/snek/model/channel_message.py b/src/snekbak/model/channel_message.py similarity index 100% rename from src/snek/model/channel_message.py rename to src/snekbak/model/channel_message.py diff --git a/src/snek/model/notification.py b/src/snekbak/model/notification.py similarity index 100% rename from src/snek/model/notification.py rename to src/snekbak/model/notification.py diff --git a/src/snek/model/user.py b/src/snekbak/model/user.py similarity index 100% rename from src/snek/model/user.py rename to src/snekbak/model/user.py diff --git a/src/snek/service/__init__.py b/src/snekbak/service/__init__.py similarity index 100% rename from src/snek/service/__init__.py rename to src/snekbak/service/__init__.py diff --git a/src/snek/service/channel.py b/src/snekbak/service/channel.py similarity index 100% rename from src/snek/service/channel.py rename to src/snekbak/service/channel.py diff --git a/src/snek/service/channel_member.py b/src/snekbak/service/channel_member.py similarity index 100% rename from src/snek/service/channel_member.py rename to src/snekbak/service/channel_member.py diff --git a/src/snek/service/channel_message.py b/src/snekbak/service/channel_message.py similarity index 100% rename from src/snek/service/channel_message.py rename to src/snekbak/service/channel_message.py diff --git a/src/snek/service/chat.py b/src/snekbak/service/chat.py similarity index 100% rename from src/snek/service/chat.py rename to src/snekbak/service/chat.py diff --git a/src/snek/service/notification.py b/src/snekbak/service/notification.py similarity index 100% rename from src/snek/service/notification.py rename to src/snekbak/service/notification.py diff --git a/src/snek/service/socket.py b/src/snekbak/service/socket.py similarity index 100% rename from src/snek/service/socket.py rename to src/snekbak/service/socket.py diff --git a/src/snek/service/user.py b/src/snekbak/service/user.py similarity index 100% rename from src/snek/service/user.py rename to src/snekbak/service/user.py diff --git a/src/snek/service/util.py b/src/snekbak/service/util.py similarity index 100% rename from src/snek/service/util.py rename to src/snekbak/service/util.py diff --git a/src/snek/static/app.js b/src/snekbak/static/app.js similarity index 100% rename from src/snek/static/app.js rename to src/snekbak/static/app.js diff --git a/src/snek/static/audio/soundfx.d_alarm1.mp3 b/src/snekbak/static/audio/soundfx.d_alarm1.mp3 similarity index 100% rename from src/snek/static/audio/soundfx.d_alarm1.mp3 rename to src/snekbak/static/audio/soundfx.d_alarm1.mp3 diff --git a/src/snek/static/audio/soundfx.d_alarm2.mp3 b/src/snekbak/static/audio/soundfx.d_alarm2.mp3 similarity index 100% rename from src/snek/static/audio/soundfx.d_alarm2.mp3 rename to src/snekbak/static/audio/soundfx.d_alarm2.mp3 diff --git a/src/snek/static/audio/soundfx.d_beep1.mp3 b/src/snekbak/static/audio/soundfx.d_beep1.mp3 similarity index 100% rename from src/snek/static/audio/soundfx.d_beep1.mp3 rename to src/snekbak/static/audio/soundfx.d_beep1.mp3 diff --git a/src/snek/static/audio/soundfx.d_beep2.mp3 b/src/snekbak/static/audio/soundfx.d_beep2.mp3 similarity index 100% rename from src/snek/static/audio/soundfx.d_beep2.mp3 rename to src/snekbak/static/audio/soundfx.d_beep2.mp3 diff --git a/src/snek/static/audio/soundfx.d_beep3.mp3 b/src/snekbak/static/audio/soundfx.d_beep3.mp3 similarity index 100% rename from src/snek/static/audio/soundfx.d_beep3.mp3 rename to src/snekbak/static/audio/soundfx.d_beep3.mp3 diff --git a/src/snek/static/base.css b/src/snekbak/static/base.css similarity index 100% rename from src/snek/static/base.css rename to src/snekbak/static/base.css diff --git a/src/snek/static/chat-input.js b/src/snekbak/static/chat-input.js similarity index 100% rename from src/snek/static/chat-input.js rename to src/snekbak/static/chat-input.js diff --git a/src/snek/static/chat-window.js b/src/snekbak/static/chat-window.js similarity index 100% rename from src/snek/static/chat-window.js rename to src/snekbak/static/chat-window.js diff --git a/src/snek/static/fancy-button.js b/src/snekbak/static/fancy-button.js similarity index 100% rename from src/snek/static/fancy-button.js rename to src/snekbak/static/fancy-button.js diff --git a/src/snek/static/generic-form.css b/src/snekbak/static/generic-form.css similarity index 100% rename from src/snek/static/generic-form.css rename to src/snekbak/static/generic-form.css diff --git a/src/snek/static/generic-form.js b/src/snekbak/static/generic-form.js similarity index 100% rename from src/snek/static/generic-form.js rename to src/snekbak/static/generic-form.js diff --git a/src/snek/static/html-frame.css b/src/snekbak/static/html-frame.css similarity index 100% rename from src/snek/static/html-frame.css rename to src/snekbak/static/html-frame.css diff --git a/src/snek/static/html-frame.js b/src/snekbak/static/html-frame.js similarity index 100% rename from src/snek/static/html-frame.js rename to src/snekbak/static/html-frame.js diff --git a/src/snek/static/manifest.json b/src/snekbak/static/manifest.json similarity index 100% rename from src/snek/static/manifest.json rename to src/snekbak/static/manifest.json diff --git a/src/snek/static/markdown-frame.js b/src/snekbak/static/markdown-frame.js similarity index 100% rename from src/snek/static/markdown-frame.js rename to src/snekbak/static/markdown-frame.js diff --git a/src/snek/static/message-list-manager.js b/src/snekbak/static/message-list-manager.js similarity index 100% rename from src/snek/static/message-list-manager.js rename to src/snekbak/static/message-list-manager.js diff --git a/src/snek/static/message-list.js b/src/snekbak/static/message-list.js similarity index 100% rename from src/snek/static/message-list.js rename to src/snekbak/static/message-list.js diff --git a/src/snek/static/models.js b/src/snekbak/static/models.js similarity index 100% rename from src/snek/static/models.js rename to src/snekbak/static/models.js diff --git a/src/snek/static/register__.css b/src/snekbak/static/register__.css similarity index 100% rename from src/snek/static/register__.css rename to src/snekbak/static/register__.css diff --git a/src/snek/static/schedule.js b/src/snekbak/static/schedule.js similarity index 100% rename from src/snek/static/schedule.js rename to src/snekbak/static/schedule.js diff --git a/src/snek/static/style.css b/src/snekbak/static/style.css similarity index 100% rename from src/snek/static/style.css rename to src/snekbak/static/style.css diff --git a/src/snek/system/__init__.py b/src/snekbak/system/__init__.py similarity index 100% rename from src/snek/system/__init__.py rename to src/snekbak/system/__init__.py diff --git a/src/snek/system/api.py b/src/snekbak/system/api.py similarity index 100% rename from src/snek/system/api.py rename to src/snekbak/system/api.py diff --git a/src/snek/system/cache.py b/src/snekbak/system/cache.py similarity index 100% rename from src/snek/system/cache.py rename to src/snekbak/system/cache.py diff --git a/src/snek/system/form.py b/src/snekbak/system/form.py similarity index 100% rename from src/snek/system/form.py rename to src/snekbak/system/form.py diff --git a/src/snek/system/http.py b/src/snekbak/system/http.py similarity index 100% rename from src/snek/system/http.py rename to src/snekbak/system/http.py diff --git a/src/snek/system/mapper.py b/src/snekbak/system/mapper.py similarity index 100% rename from src/snek/system/mapper.py rename to src/snekbak/system/mapper.py diff --git a/src/snek/system/markdown.py b/src/snekbak/system/markdown.py similarity index 100% rename from src/snek/system/markdown.py rename to src/snekbak/system/markdown.py diff --git a/src/snek/system/middleware.py b/src/snekbak/system/middleware.py similarity index 100% rename from src/snek/system/middleware.py rename to src/snekbak/system/middleware.py diff --git a/src/snek/system/model.py b/src/snekbak/system/model.py similarity index 100% rename from src/snek/system/model.py rename to src/snekbak/system/model.py diff --git a/src/snek/system/object.py b/src/snekbak/system/object.py similarity index 100% rename from src/snek/system/object.py rename to src/snekbak/system/object.py diff --git a/src/snek/system/security.py b/src/snekbak/system/security.py similarity index 100% rename from src/snek/system/security.py rename to src/snekbak/system/security.py diff --git a/src/snek/system/service.py b/src/snekbak/system/service.py similarity index 100% rename from src/snek/system/service.py rename to src/snekbak/system/service.py diff --git a/src/snek/system/view.py b/src/snekbak/system/view.py similarity index 100% rename from src/snek/system/view.py rename to src/snekbak/system/view.py diff --git a/src/snek/templates/about.html b/src/snekbak/templates/about.html similarity index 100% rename from src/snek/templates/about.html rename to src/snekbak/templates/about.html diff --git a/src/snek/templates/about.md b/src/snekbak/templates/about.md similarity index 100% rename from src/snek/templates/about.md rename to src/snekbak/templates/about.md diff --git a/src/snek/templates/base.html b/src/snekbak/templates/base.html similarity index 100% rename from src/snek/templates/base.html rename to src/snekbak/templates/base.html diff --git a/src/snek/templates/base_chat.html b/src/snekbak/templates/base_chat.html similarity index 100% rename from src/snek/templates/base_chat.html rename to src/snekbak/templates/base_chat.html diff --git a/src/snek/templates/docs.html b/src/snekbak/templates/docs.html similarity index 100% rename from src/snek/templates/docs.html rename to src/snekbak/templates/docs.html diff --git a/src/snek/templates/docs.md b/src/snekbak/templates/docs.md similarity index 100% rename from src/snek/templates/docs.md rename to src/snekbak/templates/docs.md diff --git a/src/snek/templates/index.html b/src/snekbak/templates/index.html similarity index 100% rename from src/snek/templates/index.html rename to src/snekbak/templates/index.html diff --git a/src/snek/templates/login.html b/src/snekbak/templates/login.html similarity index 100% rename from src/snek/templates/login.html rename to src/snekbak/templates/login.html diff --git a/src/snek/templates/message.html b/src/snekbak/templates/message.html similarity index 100% rename from src/snek/templates/message.html rename to src/snekbak/templates/message.html diff --git a/src/snek/templates/register.html b/src/snekbak/templates/register.html similarity index 100% rename from src/snek/templates/register.html rename to src/snekbak/templates/register.html diff --git a/src/snek/templates/test2.html b/src/snekbak/templates/test2.html similarity index 100% rename from src/snek/templates/test2.html rename to src/snekbak/templates/test2.html diff --git a/src/snek/templates/web.html b/src/snekbak/templates/web.html similarity index 100% rename from src/snek/templates/web.html rename to src/snekbak/templates/web.html diff --git a/src/snek/view/__init__.py b/src/snekbak/view/__init__.py similarity index 100% rename from src/snek/view/__init__.py rename to src/snekbak/view/__init__.py diff --git a/src/snek/view/about.py b/src/snekbak/view/about.py similarity index 100% rename from src/snek/view/about.py rename to src/snekbak/view/about.py diff --git a/src/snek/view/docs.py b/src/snekbak/view/docs.py similarity index 100% rename from src/snek/view/docs.py rename to src/snekbak/view/docs.py diff --git a/src/snek/view/index.py b/src/snekbak/view/index.py similarity index 100% rename from src/snek/view/index.py rename to src/snekbak/view/index.py diff --git a/src/snek/view/login.py b/src/snekbak/view/login.py similarity index 100% rename from src/snek/view/login.py rename to src/snekbak/view/login.py diff --git a/src/snek/view/login_form.py b/src/snekbak/view/login_form.py similarity index 100% rename from src/snek/view/login_form.py rename to src/snekbak/view/login_form.py diff --git a/src/snek/view/logout.py b/src/snekbak/view/logout.py similarity index 100% rename from src/snek/view/logout.py rename to src/snekbak/view/logout.py diff --git a/src/snek/view/register.py b/src/snekbak/view/register.py similarity index 100% rename from src/snek/view/register.py rename to src/snekbak/view/register.py diff --git a/src/snek/view/register_form.py b/src/snekbak/view/register_form.py similarity index 100% rename from src/snek/view/register_form.py rename to src/snekbak/view/register_form.py diff --git a/src/snek/view/rpc.py b/src/snekbak/view/rpc.py similarity index 100% rename from src/snek/view/rpc.py rename to src/snekbak/view/rpc.py diff --git a/src/snek/view/status.py b/src/snekbak/view/status.py similarity index 100% rename from src/snek/view/status.py rename to src/snekbak/view/status.py diff --git a/src/snek/view/web.py b/src/snekbak/view/web.py similarity index 100% rename from src/snek/view/web.py rename to src/snekbak/view/web.py