- @for item in data.items
+ @for item in carousel.items
diff --git a/web/components/contact/html.v b/web/components/contact/html.v
new file mode 100644
index 0000000..04bcde1
--- /dev/null
+++ b/web/components/contact/html.v
@@ -0,0 +1,5 @@
+module contact
+
+fn (c ContactPage) html() string {
+ return $tmpl('./contact.html')
+}
\ No newline at end of file
diff --git a/web/components/contact/model.v b/web/components/contact/model.v
new file mode 100644
index 0000000..3bb2ea5
--- /dev/null
+++ b/web/components/contact/model.v
@@ -0,0 +1,15 @@
+module contact
+
+struct ContactPage {
+ address string
+ phone string
+ email string
+}
+
+fn default_contact_page() ContactPage {
+ return ContactPage{
+ address: '121 King Street, Melbourne, Australia'
+ phone: '+123 456 789 000'
+ email: 'company@email.com'
+ }
+}
\ No newline at end of file
diff --git a/web/components/contact/templates/contact.html b/web/components/contact/templates/contact.html
new file mode 100644
index 0000000..b40707b
--- /dev/null
+++ b/web/components/contact/templates/contact.html
@@ -0,0 +1,62 @@
+
+
+
+
Contact Page
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/web/components/intro/render.v b/web/components/intro/render.v
deleted file mode 100644
index 179bb8d..0000000
--- a/web/components/intro/render.v
+++ /dev/null
@@ -1,114 +0,0 @@
-module intro
-
-import freeflowuniverse.crystallib.core.playbook
-
-pub struct Item {
-pub mut:
- title string
- subtitle string
- description string
- background_image string
- button_primary Button
- button_secondary Button
-}
-
-pub struct Button {
-pub mut:
- text string
- url string
-}
-
-pub struct Data {
-pub mut:
- items []Item
-}
-
-
-const example_heroscript="
-
- !!intro1.new name:'myintro'
-
- !!intro1.myintro_add
- title: 'Sepia'
- description: '
- Made for photographers, photo studios, design agencies.
- Create your own unique and beautiful photography website!
- '
- subtitle: 'Photography Portfolio Theme'
- background_image: 'assets/img/intro/intro-10.jpg'
- button_primary_text: 'Buy It Now!'
- button_primary_url: 'https://example.com/learn-more'
- button_secondary_text: 'Discover More'
- button_secondary_url: 'albums-grid-fluid-2.html'
-
- !!intro1.myintro_add
- title: 'Sepia 2'
- description: 'Made for photographers 2, photo studios, design agencies.
Create your own unique and beautiful photography website!'
- subtitle: 'Photography Portfolio Theme'
- background_image: 'assets/img/intro/intro-10.jpg'
- button_primary_text: 'Buy It Now!'
- button_primary_url: 'https://example.com/learn-more'
- button_secondary_text: 'Discover More'
- button_secondary_url: 'albums-grid-fluid-2.html'
-"
-
-@[params]
-pub struct RenderArgs{
-pub mut:
- text string
- args map[string]string
- defaults bool
-}
-
-//will have all the results, key is in this case intro1.${name}
-//this allows us to feed e.g. markdown to all renderers and then we get the data filled in what is found on page
-
-pub fn render(args_ RenderArgs) !map[string]string{
- mut args:=args_
-
- mut result:=map[string]string{}
-
- if args.text =="" && args.defaults{
- args.text = example_heroscript
- }
-
- mut plbook := playbook.new(text: args.text)!
- mut data := Data{}
-
- actions0 := plbook.find(filter: 'intro1.new')!
- for action0 in actions0{
- mut p0 := action0.params
- name := p0.get_default('name','default')!
- key:="intro1.${name}"
-
- // Process add_item actions
- actions := plbook.find(filter: 'intro1.${name}_add')!
- for action in actions {
- mut p := action.params
-
- item := Item{
- title: p.get('title')!
- subtitle: p.get('subtitle')!
- description: p.get('description')!.replace("\n","
")
- background_image: p.get('background_image')!
- button_primary: Button{
- text: p.get('button_primary_text')!
- url: p.get('button_primary_url')!
- }
- button_secondary: Button{
- text: p.get('button_secondary_text')!
- url: p.get('button_secondary_url')!
- }
- }
-
- data.items << item
- }
-
- result[key]=$tmpl("templates/main.html")
-
- }
-
- return result
-
-
-}
\ No newline at end of file
diff --git a/web/content/index.md b/web/content/index.md
new file mode 100644
index 0000000..e69de29
diff --git a/web/render.v b/web/render.v
new file mode 100644
index 0000000..bb4f9cf
--- /dev/null
+++ b/web/render.v
@@ -0,0 +1,75 @@
+module web
+
+import freeflowuniverse.crystallib.core.playbook
+import veb
+import web.components.carousel
+import freeflowuniverse.crystallib.ui.console
+import os
+
+pub fn render(mut ctx Context) !map[string]string {
+ mut components := map[string]string{}
+
+ mut plbook := playbook.new(text: carousel.example_heroscript)!
+ carousels := carousel.play(mut plbook)!
+
+ for key, carousel in carousels {
+ if key in components {
+ panic('this should never happen')
+ }
+ components[key] = carousel.html()
+ }
+
+ //todo: here we need to add all renders we support
+ // if true{
+ // println(res)
+ // exit(1)
+ // }
+
+ return components
+}
+
+pub fn template_render(path string, content map[string]string)!string {
+ mut name:=os.base(path).to_lower()
+ name=name.all_before_last(".html")
+ c := match name{
+ "index"{
+ $tmpl('./templates/index.html')
+ }"blog-list-classic"{
+ $tmpl('./templates/blog-list-classic.html')
+ }else{
+ return error("can't find template with name: ${name}")
+ }
+ }
+ //TODO: NEED to add the other templates, its a pitty we can't do this dynamic
+ return c
+}
+
+pub fn (mut app App) index(mut ctx Context) veb.Result {
+ return app.index2(mut ctx ,"")
+}
+
+@['/:path']
+pub fn (mut app App) index2(mut ctx Context,path string) veb.Result {
+ mut templpath:="${path}"
+ if templpath==""{
+ templpath="index"
+ }
+ println(templpath)
+ console.print_debug("templpath : '${templpath}'")
+
+ content:=render(mut ctx) or {
+ ctx.res.set_status(.unknown)
+ return ctx.html('
ERROR!
${err}')
+ }
+ // mut tmp_var := map[string]dtm.DtmMultiTypeMap{}
+ // for key,val in content{
+ // tmp_var[key] = val
+ // }
+ //t:=app.dtm.expand(templpath,placeholders:&tmp_var)
+ t:= template_render(templpath,content)or {
+ ctx.res.set_status(.unknown)
+ return ctx.html('
ERROR TEMPLATE!
${err}')
+ }
+ return ctx.html(t)
+}
+
diff --git a/web/templates/albums-archive.html b/web/templates/albums-archive.html
index 2564195..eb13c3f 100644
--- a/web/templates/albums-archive.html
+++ b/web/templates/albums-archive.html
@@ -36,16 +36,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
diff --git a/web/view.v b/web/view.v
index 7d2eff5..b4ba350 100644
--- a/web/view.v
+++ b/web/view.v
@@ -1,86 +1,21 @@
module web
-//import freeflowuniverse.crystallib.osal
import veb
-import web1.components.intro
+import web.components.carousel
import freeflowuniverse.crystallib.ui.console
-// import rand
+import freeflowuniverse.crystallib.core.playbook
import os
-// import json
-// import freeflowuniverse.crystallib.webserver.auth.jwt
-// import time
-//import x.templating.dtm
-pub fn render(mut ctx Context) !map[string]string {
- mut res:=map[string]string{}
- res=intro.render(defaults:true)!
- //todo: here we need to add all renders we support
- // if true{
- // println(res)
- // exit(1)
- // }
-
- return res
-}
-
-pub fn template_render(path string, content map[string]string)!string {
- mut name:=os.base(path).to_lower()
- name=name.all_before_last(".html")
- c := match name{
- "index"{
- $tmpl('./templates/index.html')
- }"blog-list-classic"{
- $tmpl('./templates/blog-list-classic.html')
- }else{
- return error("can't find template with name: ${name}")
- }
+pub fn (app &App) carousel(mut ctx Context) veb.Result {
+ mut plbook := playbook.new(text: carousel.example_heroscript) or {
+ return ctx.server_error(err.str())
}
- //TODO: NEED to add the other templates, its a pitty we can't do this dynamic
- return c
-}
-
-pub fn (mut app App) index(mut ctx Context) veb.Result {
- return app.index2(mut ctx ,"")
-}
-
-@['/:path']
-pub fn (mut app App) index2(mut ctx Context,path string) veb.Result {
- mut templpath:="${path}"
- if templpath==""{
- templpath="index"
+ components := carousel.play(mut plbook) or {
+ return ctx.server_error(err.str())
}
- println(templpath)
- console.print_debug("templpath : '${templpath}'")
-
- content:=render(mut ctx) or {
- ctx.res.set_status(.unknown)
- return ctx.html('
ERROR!
${err}')
- }
- // mut tmp_var := map[string]dtm.DtmMultiTypeMap{}
- // for key,val in content{
- // tmp_var[key] = val
- // }
- //t:=app.dtm.expand(templpath,placeholders:&tmp_var)
- t:= template_render(templpath,content)or {
- ctx.res.set_status(.unknown)
- return ctx.html('
ERROR TEMPLATE!
${err}')
- }
- return ctx.html(t)
+ return ctx.html(components['intro1.myintro'].html())
}
-// @['/api/connection-details'; get]
-// pub fn (app &App) participant_endpoint(mut ctx Context) veb.Result {
-
-// @['/blogs/']
-// pub fn (app &App) room(mut ctx Context) veb.Result {
-// return ctx.html($tmpl('./templates/room.html'))
-// }
-
-// pub fn (app &App) custom(mut ctx Context) veb.Result {
-// dollar := '$'
-// return ctx.html($tmpl('./templates/blog-list-grid.html'))
-// }
-
// // Custom 404 handler
pub fn (mut ctx Context) not_found() veb.Result {
ctx.res.set_status(.not_found)