From 7ad3f984718a2b541f848895816bdc309ff892b2 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Sat, 15 Mar 2025 04:14:02 +0700 Subject: [PATCH] Giving a sample page --- config/directory.py | 3 +- handler.py | 12 +++ modules/sample/prime.py | 125 ++++++++++++++++++++++++++++ pages/sample/prime.html | 180 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 319 insertions(+), 1 deletion(-) create mode 100644 modules/sample/prime.py create mode 100644 pages/sample/prime.html diff --git a/config/directory.py b/config/directory.py index 366d6c2..dc61e08 100644 --- a/config/directory.py +++ b/config/directory.py @@ -1,7 +1,8 @@ from core import template page = { - 'public' :'pages/public' + 'public' :'pages/public', + 'sample' :'pages/sample' } static = [ diff --git a/handler.py b/handler.py index 64ae435..476a23d 100644 --- a/handler.py +++ b/handler.py @@ -9,7 +9,9 @@ from bottle import Bottle, route from config import directory import templates.plain.main as template_public +import templates.prime.main as template_sample_prime import modules.public.home as public_home +import modules.sample.prime as sample_prime app = Bottle() @@ -21,3 +23,13 @@ def index(): } } return public_home.main().html(params) + +@app.route('/sample/prime') +def index(): + params = { + "mako":{ + "website" : template_sample_prime.main(directory.page["sample"], "prime") + } + } + return sample_prime.main().html(params) + diff --git a/modules/sample/prime.py b/modules/sample/prime.py new file mode 100644 index 0000000..87cb583 --- /dev/null +++ b/modules/sample/prime.py @@ -0,0 +1,125 @@ +from mako.template import Template +from config import globalvar + +class main: + + def __init__(self): + pass + + def html(self, params): + title = "CostaPy" + + user_roles = [1,2] # A roles that user have + active_page = "Sample" # Current active page name + + copyright = "Copyright (C) 2022 Dita Aji Pratama" + greeting = "A prime dashboard based on bootstrap 5" + + menu_navbar = [ + { + "name":"Home", + "target":"_self", + "href":"#", + "notification":0, + "roles":[1,2] + }, + { + "name":"Customize", + "href":"#", + "target":"_self", + "notification":0, + "roles":[1,2] + }, + { + "name":"Notification", + "href":"#", + "target":"_self", + "notification":1, + "roles":[1,2] + } + ] + + menu_profile = { + "picture": "https://ditaajipratama.net/img/no-profile-donut.png", + "name" : "Dita Aji Pratama", + "menu" : [ + { + "name" :"Profile", + "href" :"/profile", + "target":"_self", + "roles" :[1,2] + }, + { + "name" :"Settings", + "href" :"/settings", + "target":"_self", + "roles" :[1,2] + }, + { + "name" :"Logout", + "href" :"/logout", + "target":"_self", + "roles" :[1,2,3] + } + ] + } + + menu_sidebar = [ + { + "icon":"fa-solid fa-gauge", + "name":"Dashboard", + "target":"_self", + "href":"#", + "roles":[1,2] + }, + { + "icon":"fa-solid fa-users", + "name":"Users", + "target":"_self", + "href":"#", + "roles":[1,2] + }, + { + "icon":"fa-solid fa-book", + "name":"Items", + "target":"_self", + "href":"#", + "roles":[1,2] + }, + { + "icon":"fa-solid fa-book", + "name":"Analytic", + "target":"_self", + "href":"#", + "roles":[1,2] + }, + { + "icon":"fa-solid fa-book", + "name":"Reports", + "target":"_self", + "href":"#", + "roles":[1,2] + } + ] + + return Template(params["mako"]["website"]['index']).render( + title = title, + navbar = Template(params["mako"]["website"]['navbar']).render( + title = title, + menu = menu_navbar, + profile = menu_profile, + user_roles = user_roles, + active_page = active_page + ), + sidebar = Template(params["mako"]["website"]['sidebar']).render( + menu = menu_sidebar, + user_roles = user_roles, + active_page = active_page + ), + footer = Template(params["mako"]["website"]['footer']).render( + copyright = copyright, + ), + container = Template(params["mako"]["website"]['container']).render( + greeting = greeting + ) + ) diff --git a/pages/sample/prime.html b/pages/sample/prime.html new file mode 100644 index 0000000..c004ba8 --- /dev/null +++ b/pages/sample/prime.html @@ -0,0 +1,180 @@ +
+

CostaPy Template - Prime

+

${greeting}

+

Usage

+ +

License

+

MIT License

+

Copyright (c) 2024 Dita Aji Pratama

+

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:

+

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

+

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.

+
+ + + + + + + + + + + + +