Skip to content

Commit

Permalink
Merge pull request #119 from FifthTry/feat/multi-templ
Browse files Browse the repository at this point in the history
Enable support for multiple templates in /create-site/
  • Loading branch information
siddhantk232 authored Nov 13, 2024
2 parents cee8c47 + 8b08a8f commit 5bcc0f8
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 58 deletions.
12 changes: 11 additions & 1 deletion actions/create-site-action.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ ftd.string-field $site_slug:
ftd.boolean-field public_source:
js: $assets.files.assets.functions.js

callAlert("creating site: " + site_slug.value + ", under org: " + org_slash_username + " is public: ", public_source.value)
callAlert("creating site: " + site_slug.value + ", under org: " + org_slash_username + " is public: " + public_source.value)


-- void submit-with-templ(org_slash_username, site_slug, public_source, sample_site_id):
string org_slash_username:
ftd.string-field $site_slug:
ftd.boolean-field public_source:
ftd.integer-field sample_site_id:
js: $assets.files.assets.functions.js

callAlert("creating site with templ: " + site_slug.value + ", under org: " + org_slash_username + " is public: " + public_source.value + " sample site: " + sample_site_id.value)
2 changes: 1 addition & 1 deletion components/featured/page.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ud.user-data user-data:
template-record.template list templates:
children children:

-- ds.page: FifthTry | Better way To Build Websites
-- ds.page: Templates
spacing: $ds.spaces.vertical-gap.small.gap
margin: $ds.spaces.vertical-gap.zero

Expand Down
90 changes: 82 additions & 8 deletions components/sites/create-site.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
-- import: ui.fifthtry.com/components/label as l
-- import: ui.fifthtry.com/actions/create-site-action
-- import: ui.fifthtry.com/utils as u
-- import: ui.fifthtry.com/records/sites as site-records


-- component create-site:
string org-slash-username:
string org-slug:
module create-site-action: create-site-action
string dashboard-url:
optional site-records.sample-site-data sample-site:


-- ds.section-column:

Expand Down Expand Up @@ -59,6 +62,28 @@ string dashboard-url:

-- end: ds.column

-- ds.row:
align-content: left
spacing: $ds.spaces.horizontal-gap.small
if: { create-site.sample-site }

-- ds.copy-small: $use-template-text(title=$create-site.sample-site.title, link=$create-site.sample-site.ide-link)

-- end: ds.row

-- ds.row:
align-content: left
spacing: $ds.spaces.horizontal-gap.small
if: { !create-site.sample-site }

-- ds.copy-small: $featured-page-msg(org = $create-site.org-slug)
if: { create-site.org-slug != "" }

-- ds.copy-small: This site will be created using a Blog template. Browse [community templates](/featured/) for more.
if: { create-site.org-slug == "" }

-- end: ds.row

-- ds.column:
align-content: top-left

Expand All @@ -82,10 +107,17 @@ string dashboard-url:
-- ds.row:
spacing: $ds.spaces.horizontal-gap.medium

-- ds.primary-button: Create Site With Template
if: { create-site.sample-site }
width: full
radius: curved
$on-click$: $create-site.create-site-action.submit-with-templ(org_slash_username = $create-site.org-slug, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source, sample_site_id = $create-site.sample-site.id)

-- ds.primary-button: Create Site
if: { !create-site.sample-site }
width: full
radius: curved
$on-click$: $create-site.create-site-action.submit(org_slash_username = $create-site.org-slash-username, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source)
$on-click$: $create-site.create-site-action.submit(org_slash_username = $create-site.org-slug, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source)

-- ds.secondary-button: Cancel
width: full
Expand Down Expand Up @@ -143,8 +175,31 @@ string dashboard-url:

-- end: ds.column

-- ds.column:
align-content: left
spacing: $ds.spaces.horizontal-gap.small
if: { create-site.sample-site }

-- ds.copy-small: $use-template-text(title=$create-site.sample-site.title, link=$create-site.sample-site.ide-link)

-- end: ds.column

-- ds.column:
align-content: left
spacing: $ds.spaces.horizontal-gap.small
if: { !create-site.sample-site }

-- ds.copy-small: $featured-page-msg(org = $create-site.org-slug)
if: { create-site.org-slug != "" }

-- ds.copy-small: This site will be created using a Blog template. Browse [community templates](/featured/) for more.
if: { create-site.org-slug == "" }

-- end: ds.column

-- ds.column:
align-content: top-left
spacing: $ds.spaces.horizontal-gap.small

-- ds.checkbox: Make site public so that others can view source of your site
$is-checked: $create-site.create-site-action.public-source.value
Expand All @@ -166,12 +221,19 @@ string dashboard-url:

-- ds.column:
spacing: $ds.spaces.vertical-gap.medium

-- ds.primary-button: Create Site
width: full
radius: curved
$on-click$: $create-site.create-site-action.submit(org_slash_username = $create-site.org-slash-username, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source)


-- ds.primary-button: Create Site With Template
if: { create-site.sample-site }
width: full
radius: curved
$on-click$: $create-site.create-site-action.submit-with-templ(org_slash_username = $create-site.org-slug, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source, sample_site_id = $create-site.sample-site.id)

-- ds.primary-button: Create Site
if: { !create-site.sample-site }
width: full
radius: curved
$on-click$: $create-site.create-site-action.submit(org_slash_username = $create-site.org-slug, $site_slug = $create-site.create-site-action.site-slug, public_source = $create-site.create-site-action.public-source)

-- ds.secondary-button: Cancel
width: full
radius: curved
Expand All @@ -186,3 +248,15 @@ string dashboard-url:
-- end: ds.section-column

-- end: create-site

-- string use-template-text(title, link):
string title:
string link:


"This site will be created using [" + title + "](" + link + ")."

-- string featured-page-msg(org):
string org:

"This site will be created using a Blog template. Browse [community templates](/featured/?r=" + org + ") for more."
38 changes: 36 additions & 2 deletions pages/featured/index.ftd
Original file line number Diff line number Diff line change
@@ -1,13 +1,47 @@
-- import: ui.fifthtry.com/components/featured/page as p
-- import: ui.fifthtry.com/site-data
-- import: ui.fifthtry.com/records/user-data as ud
-- import: ui.fifthtry.com/records/sites as templates-record
-- import: ui.fifthtry.com/records/sites as site-records
-- import: ui.fifthtry.com/pages/featured/template

-- site-records.template list templates:

-- site-records.template:
title: Blog Template
preview-url: https://blog.fifthtry.site/
preview-img: $assets.files.assets.templates.blog-temp.png
slug: blog

-- site-records.template:
title: Simple Website Template
preview-url: https://simple-website-template.fifthtry.site/
preview-img: $assets.files.assets.templates.simple-ws-temp.png
slug: simple-website-template

-- site-records.template:
title: Website Template
preview-url: https://website-template.fifthtry.site/
preview-img: $assets.files.assets.templates.ws-temp.png
slug: website-template

-- site-records.template:
title: Simple Blog Template
preview-url: https://simple-blog-template.fifthtry.site/
preview-img: $assets.files.assets.templates.simple-blog-temp.png
slug: simple-blog-template

-- site-records.template:
title: Resume Template
preview-url: https://resume-template.fifthtry.site/
preview-img: $assets.files.assets.templates.resume.png
slug: resume-template

-- end: templates

-- component page:
module site-data: site-data
ud.user-data user-data:
templates-record.template list templates:
site-records.template list templates: $templates

-- p.page:
site-data: $page.site-data
Expand Down
27 changes: 21 additions & 6 deletions pages/featured/template.ftd
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
-- import: ui.fifthtry.com/records/sites as template-record
-- import: fastn/processors as pr

;; org-slug
-- optional string r:
$processor$: pr.request-data



Expand All @@ -22,7 +27,7 @@ align-content: top-left
title: $obj.title
preview-url: $obj.preview-url
preview-img: $obj.preview-img
id: $obj.id
slug: $obj.slug

-- end: ds.row

Expand All @@ -39,7 +44,7 @@ align-content: top-left
title: $obj.title
preview-url: $obj.preview-url
preview-img: $obj.preview-img
id: $obj.id
slug: $obj.slug

-- end: ds.column

Expand All @@ -62,7 +67,7 @@ align-content: top-left
string title:
string preview-url:
ftd.image-src preview-img:
integer id:
string slug:
boolean $mouse-in: false

-- ds.column:
Expand All @@ -89,14 +94,13 @@ text: $grid-of-items.title
-- ds.row:

-- ds.primary-button: Use Template
link: $grid-of-items.preview-url
link if { r }: $create-site-with-org-link(slug = $grid-of-items.slug, org = $r)
link if { !r }: $create-site-link(slug = $grid-of-items.slug)
width: full
open-in-new-tab: true

-- ds.secondary-button: Preview
width: full
link: $grid-of-items.preview-url
open-in-new-tab: true

-- end: ds.row

Expand All @@ -111,3 +115,14 @@ open-in-new-tab: true
-- ftd.color overlay-bg:
light: #00000066
dark: #00000066

-- string create-site-with-org-link(slug, org):
string slug:
string org:

"/o/" + org + "/create-site/?t=" + slug

-- string create-site-link(slug):
string slug:

"/create-site/?t=" + slug
5 changes: 4 additions & 1 deletion pages/org/create-site.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-- import: ui.fifthtry.com/components/label as l
-- import: ui.fifthtry.com/site-data
-- import: ui.fifthtry.com/records/user-data as ud
-- import: ui.fifthtry.com/records/sites as site-records
-- import: ui.fifthtry.com/actions/create-site-action
-- import: ui.fifthtry.com/utils as u

Expand All @@ -16,6 +17,7 @@ string dashboard-url:
string create-site-url:
optional string create-org-url:
optional string top-message:
optional site-records.sample-site-data sample-site:

-- p.page:
site-data: $page.site-data
Expand All @@ -27,9 +29,10 @@ hide-header: true
top-message: $page.top-message

-- create-site.create-site:
org-slash-username: $page.org-slug
org-slug: $page.org-slug
create-site-action: $page.create-site-action
dashboard-url: $page.dashboard-url
sample-site: $page.sample-site

-- end: p.page

Expand Down
5 changes: 4 additions & 1 deletion pages/user/create-site.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-- import: ui.fifthtry.com/components/label as l
-- import: ui.fifthtry.com/site-data
-- import: ui.fifthtry.com/records/user-data as ud
-- import: ui.fifthtry.com/records/sites as site-records
-- import: ui.fifthtry.com/actions/create-site-action
-- import: ui.fifthtry.com/utils as u

Expand All @@ -15,6 +16,7 @@ string dashboard-url:
string create-site-url:
optional string create-org-url:
optional string top-message:
optional site-records.sample-site-data sample-site:

-- p.page:
site-data: $page.site-data
Expand All @@ -28,9 +30,10 @@ basic-footer: true
hide-footer: true

-- create-site.create-site:
org-slash-username: $page.user-data.username
org-slug: $ftd.empty
create-site-action: $page.create-site-action
dashboard-url: $page.dashboard-url
sample-site: $page.sample-site

-- end: p.page

Expand Down
8 changes: 7 additions & 1 deletion records/sites.ftd
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ optional string url: ;; This is present when document is not provided
history-change list changes:
optional string next:

;; Sample site info
;; Used in /create-site/ page to show the template that will be used
-- record sample-site-data:
ftd.integer-field id:
string title:
string ide-link:

;; template records
-- record template:
integer id:
string slug:
string title:
string preview-url:
ftd.image-src preview-img:
Loading

0 comments on commit 5bcc0f8

Please sign in to comment.