https://github.com/thomastjdev/nim_webframework
Framework for creating websites with Nim
https://github.com/thomastjdev/nim_webframework
framework nim nim-lang webframework website website-builder
Last synced: about 2 months ago
JSON representation
Framework for creating websites with Nim
- Host: GitHub
- URL: https://github.com/thomastjdev/nim_webframework
- Owner: ThomasTJdev
- Created: 2018-12-23T12:16:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-24T13:51:12.000Z (over 6 years ago)
- Last Synced: 2025-01-26T14:48:37.969Z (4 months ago)
- Topics: framework, nim, nim-lang, webframework, website, website-builder
- Language: Nim
- Size: 92.8 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nim Webframework
This library provides a quick webpage setup. The main purpose is to provide a website frame with administration of users.
# First run
## Step 1
Rename **config/config_default.cfg** to **config/config.cfg** and insert your details and compile:```nim
nim c -d:ssl websiteframework.nim
```## Step 2
You need to create a database, append the arg "**createdb**". The library is prepared for Postgres - if you prefer SQLite, replace the import of `db_postgres` with `db_sqlite`.```nim
./websiteframework createdb
```## Step 3
To create an Admin account, append the arg "**createadmin**". Type your details and login.```nim
./websiteframework createadmin
```## Step 4
Navigate to `127.0.0.1:5000/login` and login.```nim
./websiteframework
```# User administration
## Modules
The framework comes with the following user administration:
1. View all users
2. Add user
3. Edit user
4. Delete user
5. Reset password## User roles
There are 4 main user roles, 2 alternative and 1 system administrator:
1. Admin
2. Moderator
3. User
4. Viewer
5. EmailUnconfirmed
6. Deactivated
7. AdminSys *(only for maintenance)*# Company structure
The framework is prepared for multiple different companies using the simultaneously but compartmentalized. The is done with the table `person_access`. When a user get access to a company, a row is added to this table.Therefore a user can have access to multiple companies using the same email address. If the user has access to more than 1 company, the user needs to choose the company to access on login.
If there's only going to be 1 company accessing the platform, you don't have to mind the above.
## Add and edit companies
It is only the `AdminSys` who can edit and see all companies.Navigate to `/adminsys/company/all` to manage the companies.
# Personalize
## General
To add pages you have to add a template (tmpl/\*.tmpl) and define a route (routes/\*.nim).
Let's create a new About page.
### New route
Open `resources/routes/routes_general.nim` and insert:
```nim
get "/about":
createTFD()
if not c.loggedIn:
resp genMain(c, genFormLogin(c, redirectPath=c.req.path), "Log in")
else:
resp genMain(c, genAbout(c), "About")
```### Create HTML
Add a new file: `resources/tmpl/about.tmpl` and insert:
```nim
#? stdtmpl | standard
#
#proc genAbout(c: var TData): string =
# result = ""About me
Hello world
#end proc
```### Config sidebar
Open `resources/tmpl/sidebar.tmpl` and insert a new link:
```HTML
About
```
### Let's test it
```nim
nim c -r -d:ssl websiteframework.nim
#Navigate to `127.0.0.1:5000/about`
```
# Screenshot
