Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Page templates #79

Merged
merged 84 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
db022ff
feat: Init template system
surajshetty3416 Jan 30, 2024
161565c
feat: Add option to create page with template
surajshetty3416 Feb 26, 2024
c1effef
feat: Export json of template and sync on migrate
surajshetty3416 Feb 26, 2024
8cfaee0
fix: Duplicate page from template
surajshetty3416 Feb 27, 2024
9b27e8d
fix: Update template listing
surajshetty3416 Mar 21, 2024
d5a5616
fix: Load developer_mode properly
surajshetty3416 Mar 21, 2024
5044d7a
Merge branch 'develop' into template-page
surajshetty3416 Mar 23, 2024
b742a1c
fix: Move images from template to builder_assets
surajshetty3416 Mar 26, 2024
7a77fb6
Merge branch 'develop' into template-page
surajshetty3416 Mar 26, 2024
b0fba18
Merge branch 'develop' into template-page
surajshetty3416 Mar 26, 2024
886dff6
Merge branch 'develop' into template-page
surajshetty3416 Mar 30, 2024
3e05ace
Merge branch 'develop' into template-page
surajshetty3416 Mar 30, 2024
07eb1ba
Merge branch 'develop' into template-page
surajshetty3416 Apr 1, 2024
eb881cf
feat: Add landing page template
surajshetty3416 Apr 2, 2024
158ee0c
chore: Update signup link
surajshetty3416 Apr 2, 2024
eb04343
chore: Update develop version
surajshetty3416 Apr 2, 2024
d4a433c
chore: Fix develop version
surajshetty3416 Apr 3, 2024
0850166
refactor: Reorganize builder page fields
surajshetty3416 Apr 4, 2024
b0306c2
fix: Template preview modal
surajshetty3416 Apr 4, 2024
ee1ec09
Merge branch 'develop' into template-page
surajshetty3416 Apr 4, 2024
a535ad6
fix: Add builder_assets in proxy
surajshetty3416 Apr 5, 2024
ef7ecbc
fix: Duplicate page functionality
surajshetty3416 Apr 5, 2024
297d587
Merge branch 'develop' into template-page
surajshetty3416 Apr 29, 2024
4f9ed3a
fix: Move preview image to www as well
surajshetty3416 May 9, 2024
f5c0ba5
Merge branch 'develop', remote-tracking branch 'upstream' into templa…
surajshetty3416 May 16, 2024
1e7bbb9
fix: Update template
surajshetty3416 May 16, 2024
f17fa69
fix: Remove template assets on deleting template doc
surajshetty3416 May 16, 2024
b6018b6
fix: Delete template files of document delete
surajshetty3416 May 19, 2024
9e28e7c
refactor: Move template selector to a separate file
surajshetty3416 May 20, 2024
e124aaa
Merge branch 'develop' into template-page
surajshetty3416 May 20, 2024
20463e1
fix: Rearrage fields
surajshetty3416 May 20, 2024
da93424
Merge branch 'develop' into template-page
surajshetty3416 May 27, 2024
477974d
Merge branch 'develop' into template-page
surajshetty3416 Jun 4, 2024
67a7a4e
fix: Close modal on template selection
surajshetty3416 Jun 4, 2024
f623e41
fix: Only publish if not published
surajshetty3416 Jun 4, 2024
ca9013e
Merge branch 'develop', remote-tracking branch 'upstream' into templa…
surajshetty3416 Jun 6, 2024
84e66f7
fix: Template selector style
surajshetty3416 Jun 6, 2024
96a8c1e
fix: Image upload
surajshetty3416 Jun 6, 2024
3f102d1
Merge branch 'develop' into template-page
surajshetty3416 Jun 23, 2024
c3433c3
fix: Add missing imports
surajshetty3416 Jun 24, 2024
83077d6
fix: Dark divider
surajshetty3416 Jun 24, 2024
3bed1be
fix: Option toggle for alignment
surajshetty3416 Jun 24, 2024
f40ee83
fix: Template save flow
surajshetty3416 Jun 24, 2024
0fa3bdc
fix: Page name & title created by template selector
surajshetty3416 Jun 25, 2024
10fe4f1
Discard changes to builder/__init__.py
surajshetty3416 Jun 26, 2024
f3786cb
fix: Remove develop version
surajshetty3416 Jun 26, 2024
0b6fbbe
Merge branch 'develop' into for-release
surajshetty3416 Jun 26, 2024
f364cca
Merge pull request #180 from frappe/for-release
surajshetty3416 Jun 27, 2024
51e117f
chore(release): Bumped to Version 1.10.0
frappe-bot Jun 27, 2024
85c2438
Merge branch 'develop' into template-page
surajshetty3416 Jun 27, 2024
cf1364f
fix: Export components as well with page template
surajshetty3416 Jun 28, 2024
8cec07f
fix: Nested component export
surajshetty3416 Jun 29, 2024
d6e7902
Merge branch 'develop', remote-tracking branch 'upstream' into templa…
surajshetty3416 Jun 29, 2024
23c47ef
fix: Template preview generation
surajshetty3416 Jun 29, 2024
9a4ba55
fix: Option to set link on any block
surajshetty3416 Jun 29, 2024
d7a348b
fix: Misc
surajshetty3416 Jun 30, 2024
518c81e
fix(UX): Conversion of any block to link
surajshetty3416 Jul 1, 2024
39c3173
hotfix: for v1.10.0
blaggacao Jul 2, 2024
e15a2ac
fix(Autocomplete): Show label of the value that is selected
surajshetty3416 Jun 27, 2024
91eb8b3
fix: Autocomplete font size
surajshetty3416 Jun 27, 2024
bffd819
perf: Add index to route
surajshetty3416 Jul 2, 2024
f79c460
perf: Add index to page_title
surajshetty3416 Jul 2, 2024
c24b8ae
fix: Grid layout defaults
surajshetty3416 Jul 3, 2024
23c9f82
Merge pull request #183 from frappe/for-patch-release-b
surajshetty3416 Jul 3, 2024
9a7dce6
chore(release): Bumped to Version 1.10.1
frappe-bot Jul 3, 2024
c56eb96
Merge pull request #182 from blaggacao/master
surajshetty3416 Jul 3, 2024
bd0e1b7
Merge branch 'develop' into template-page
surajshetty3416 Jul 4, 2024
1272728
fix: Use compress webp images for asset
surajshetty3416 Jul 4, 2024
b23e9e2
fix: Export scripts while saving template
surajshetty3416 Jul 7, 2024
b5f8bde
Merge branch 'develop', remote-tracking branch 'upstream' into templa…
surajshetty3416 Jul 9, 2024
56b9dcb
feat: Block Template
surajshetty3416 Jul 10, 2024
931da27
fix: Misc
surajshetty3416 Jul 10, 2024
6baa079
refactor: component canvas -> fragment canvas
surajshetty3416 Jul 10, 2024
1a7415a
fix: Update exported script on change
surajshetty3416 Jul 10, 2024
486df63
fix: Misc
surajshetty3416 Jul 10, 2024
95d0e1a
fix: Block edtitor tracking while rearraging block from layers panel
surajshetty3416 Jul 10, 2024
b9f6c8a
feat: Add video template
surajshetty3416 Jul 11, 2024
b098f2d
fix: Component creation
surajshetty3416 Jul 11, 2024
a43a277
fix: Inconsitent styles
surajshetty3416 Jul 11, 2024
481f9b4
feat: Add form-1 template
surajshetty3416 Jul 11, 2024
8c92e45
feat: Add more form options
surajshetty3416 Jul 11, 2024
1ae130d
fix: Block properties section toggle UX
surajshetty3416 Jul 11, 2024
d26f84e
fix: Show input placeholder in Editor
surajshetty3416 Jul 12, 2024
8392f0f
fix: Disable template system till we have new templates
surajshetty3416 Jul 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

__version__ = "1.0.0-dev"
__version__ = '1.10.1'

14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/button/button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"4ur2l2mc6\",\"children\":[{\"blockId\":\"3z5gwjl2f\",\"children\":[],\"baseStyles\":{\"color\":\"var(--neutral-white, #FFF)\",\"fontSize\":\"14px\",\"fontWeight\":\"420\",\"height\":\"fit-content\",\"left\":\"auto\",\"letterSpacing\":\"0.28px\",\"lineHeight\":\"115%\",\"minWidth\":\"30px\",\"position\":\"static\",\"top\":\"auto\",\"width\":\"fit-content\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"__text_block__\"],\"dataKey\":null,\"element\":\"p\",\"innerHTML\":\"<p>Button</p>\",\"customAttributes\":{}}],\"baseStyles\":{\"background\":\"#171717\",\"borderRadius\":\"4px\",\"display\":\"flex\",\"flexDirection\":\"column\",\"height\":\"fit-content\",\"padding\":\"6px 8px\",\"width\":\"fit-content\"},\"rawStyles\":{\"flex-shrink\":\"0\",\"hover:background\":\"#383838\",\"transition\":\"all 0.1s ease-out\"},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"href\":\"#\"},\"classes\":[\"__text_block__\"],\"dataKey\":null,\"blockName\":\"container\",\"element\":\"a\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-10 14:44:08.816465",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:22.716694",
"modified_by": "Administrator",
"name": "Button",
"owner": "Administrator",
"preview": "/builder_assets/Button/button.png",
"template_name": "Button"
}
14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/embed/embed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"1vw78v0md\",\"children\":[],\"baseStyles\":{\"height\":\"fit-content\",\"width\":\"fit-content\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"blockName\":\"Embed HTML\",\"element\":\"div\",\"innerHTML\":\"<div style=\\\"color:#8e8e8e;background:#f4f4f4;display:grid;width:500px;height:155px;place-items:center;font-size:16px;\\\">\\n <p>Paste HTML or double click to edit</p>\\n</div>\",\"originalElement\":\"__raw_html__\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-10 17:07:00.407251",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:18.897182",
"modified_by": "Administrator",
"name": "Embed",
"owner": "Administrator",
"preview": "/builder_assets/Embed/embed.png",
"template_name": "Embed"
}
14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/form_1/form_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"2e45tti0c\",\"children\":[{\"blockId\":\"86oxik4s9\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"32px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Full Name\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"full_name\"}},{\"blockId\":\"wzbvukqlo\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"32px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Email\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"email\"}},{\"blockId\":\"4rclutff4\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"top\":\"auto\",\"left\":\"auto\",\"width\":\"100%\",\"height\":\"150px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Message\"},\"classes\":[],\"dataKey\":null,\"element\":\"textarea\",\"customAttributes\":{\"name\":\"message\"}},{\"blockId\":\"uxry21e1i\",\"children\":[{\"blockId\":\"yjglepmnh\",\"children\":[],\"baseStyles\":{\"color\":\"var(--neutral-white, #FFF)\",\"fontSize\":\"14px\",\"fontWeight\":\"420\",\"height\":\"fit-content\",\"left\":\"auto\",\"letterSpacing\":\"0.28px\",\"lineHeight\":\"115%\",\"minWidth\":\"30px\",\"position\":\"static\",\"top\":\"auto\",\"width\":\"fit-content\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"__text_block__\"],\"dataKey\":null,\"element\":\"p\",\"innerHTML\":\"<p>Submit</p>\",\"customAttributes\":{}}],\"baseStyles\":{\"background\":\"#171717\",\"borderRadius\":\"4px\",\"display\":\"flex\",\"flexDirection\":\"column\",\"height\":\"fit-content\",\"padding\":\"6px 8px\",\"width\":\"100%\",\"justifyContent\":\"flex-start\",\"alignItems\":\"center\"},\"rawStyles\":{\"flex-shrink\":\"0\",\"hover:background\":\"#383838\",\"transition\":\"all 0.1s ease-out\"},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"\"],\"dataKey\":null,\"element\":\"button\",\"customAttributes\":{}}],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"top\":\"auto\",\"left\":\"auto\",\"width\":\"100%\",\"paddingLeft\":\"20px\",\"paddingRight\":\"20px\",\"paddingBottom\":\"20px\",\"paddingTop\":\"20px\",\"maxWidth\":\"400px\",\"gap\":\"15px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"element\":\"form\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-11 23:34:22.558908",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:10.684848",
"modified_by": "Administrator",
"name": "Form 1",
"owner": "Administrator",
"preview": "/builder_assets/Form 1/form-1.png",
"template_name": "Form 1"
}
14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/form_2/form_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"6um6dfg30\",\"children\":[{\"blockId\":\"kv3hkfwvl\",\"children\":[{\"blockId\":\"a6gbqj3zl\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":1,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"28px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{\"border-right\":\"none\",\"border-top-right-radius\":\"0px\",\"border-bottom-right-radius\":\"0px\"},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Email\",\"type\":\"email\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"email\"}}],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"row\",\"flexShrink\":1,\"height\":\"fit-content\",\"width\":\"100%\",\"overflow\":\"hidden\",\"position\":\"relative\",\"gap\":\"10px\",\"flexGrow\":0},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"blockName\":\"container\",\"element\":\"div\",\"customAttributes\":{}},{\"blockId\":\"m68wwxf5e\",\"children\":[{\"blockId\":\"0aw9cg9y7\",\"children\":[],\"baseStyles\":{\"color\":\"var(--neutral-white, #FFF)\",\"fontSize\":\"14px\",\"fontWeight\":\"420\",\"height\":\"fit-content\",\"left\":\"auto\",\"letterSpacing\":\"0.28px\",\"lineHeight\":\"115%\",\"minWidth\":\"30px\",\"position\":\"static\",\"top\":\"auto\",\"width\":\"fit-content\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"__text_block__\"],\"dataKey\":null,\"element\":\"p\",\"innerHTML\":\"<p>Sign Up</p>\",\"customAttributes\":{}}],\"baseStyles\":{\"background\":\"#171717\",\"borderRadius\":\"4px\",\"display\":\"flex\",\"flexDirection\":\"column\",\"height\":\"fit-content\",\"padding\":\"6px 8px\",\"justifyContent\":\"flex-start\",\"alignItems\":\"center\"},\"rawStyles\":{\"flex-shrink\":\"0\",\"hover:background\":\"#383838\",\"transition\":\"all 0.1s ease-out\",\"border-top-left-radius\":\"0px\",\"border-bottom-left-radius\":\"0px\"},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"\"],\"dataKey\":null,\"element\":\"button\",\"customAttributes\":{}}],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"row\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"top\":\"auto\",\"left\":\"auto\",\"width\":\"100%\",\"paddingLeft\":\"20px\",\"paddingRight\":\"20px\",\"paddingBottom\":\"20px\",\"paddingTop\":\"20px\",\"maxWidth\":\"400px\",\"gap\":\"0px\",\"justifyContent\":\"flex-start\",\"alignItems\":\"center\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"element\":\"form\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-12 00:27:46.067242",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:08.730980",
"modified_by": "Administrator",
"name": "Form 2",
"owner": "Administrator",
"preview": "/builder_assets/Form 2/form-2.png",
"template_name": "Form 2"
}
14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/form_3/form_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"6um6dfg30\",\"children\":[{\"blockId\":\"kv3hkfwvl\",\"children\":[{\"blockId\":\"a6gbqj3zl\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":1,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"32px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"First Name\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"first_name\"}},{\"blockId\":\"za6939gew\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":1,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"32px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Last Name\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"last_name\"}}],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"row\",\"flexShrink\":1,\"height\":\"fit-content\",\"width\":\"100%\",\"overflow\":\"hidden\",\"position\":\"relative\",\"gap\":\"10px\",\"flexGrow\":0},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"blockName\":\"container\",\"element\":\"div\",\"customAttributes\":{}},{\"blockId\":\"feg29l91n\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"width\":\"100%\",\"height\":\"32px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Email\"},\"classes\":[],\"dataKey\":null,\"element\":\"input\",\"customAttributes\":{\"name\":\"email\"}},{\"blockId\":\"j267ivzos\",\"children\":[],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"top\":\"auto\",\"left\":\"auto\",\"width\":\"100%\",\"height\":\"150px\",\"borderRadius\":\"4px\",\"borderColor\":\"#c9c9c9\",\"borderWidth\":\"1px\",\"borderStyle\":\"solid\",\"fontSize\":\"14px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"placeholder\":\"Message\"},\"classes\":[],\"dataKey\":null,\"element\":\"textarea\",\"customAttributes\":{\"name\":\"message\"}},{\"blockId\":\"m68wwxf5e\",\"children\":[{\"blockId\":\"0aw9cg9y7\",\"children\":[],\"baseStyles\":{\"color\":\"var(--neutral-white, #FFF)\",\"fontSize\":\"14px\",\"fontWeight\":\"420\",\"height\":\"fit-content\",\"left\":\"auto\",\"letterSpacing\":\"0.28px\",\"lineHeight\":\"115%\",\"minWidth\":\"30px\",\"position\":\"static\",\"top\":\"auto\",\"width\":\"fit-content\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"__text_block__\"],\"dataKey\":null,\"element\":\"p\",\"innerHTML\":\"<p>Submit</p>\",\"customAttributes\":{}}],\"baseStyles\":{\"background\":\"#171717\",\"borderRadius\":\"4px\",\"display\":\"flex\",\"flexDirection\":\"column\",\"height\":\"fit-content\",\"padding\":\"6px 8px\",\"width\":\"100%\",\"justifyContent\":\"flex-start\",\"alignItems\":\"center\"},\"rawStyles\":{\"flex-shrink\":\"0\",\"hover:background\":\"#383838\",\"transition\":\"all 0.1s ease-out\"},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[\"\"],\"dataKey\":null,\"element\":\"button\",\"customAttributes\":{}}],\"baseStyles\":{\"display\":\"flex\",\"flexDirection\":\"column\",\"flexShrink\":0,\"overflow\":\"hidden\",\"position\":\"static\",\"top\":\"auto\",\"left\":\"auto\",\"width\":\"100%\",\"paddingLeft\":\"20px\",\"paddingRight\":\"20px\",\"paddingBottom\":\"20px\",\"paddingTop\":\"20px\",\"maxWidth\":\"400px\",\"gap\":\"15px\",\"justifyContent\":\"flex-start\",\"alignItems\":\"center\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{},\"classes\":[],\"dataKey\":null,\"element\":\"form\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-12 00:19:26.657647",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:05.223217",
"modified_by": "Administrator",
"name": "Form 3",
"owner": "Administrator",
"preview": "/builder_assets/Form 3/form-3.png",
"template_name": "Form 3"
}
14 changes: 14 additions & 0 deletions builder/builder/builder_block_template/video/video.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"block": "{\"blockId\":\"69xrb0gy4\",\"children\":[],\"baseStyles\":{\"objectFit\":\"cover\",\"width\":\"550px\"},\"rawStyles\":{},\"mobileStyles\":{},\"tabletStyles\":{},\"attributes\":{\"autoplay\":\"\",\"muted\":\"\",\"src\":\"https://cdn.free-stock.video/2152023/wave-nature-waves-ocean-water-sand-water-23350-small.mp4\"},\"classes\":[],\"dataKey\":null,\"element\":\"video\",\"customAttributes\":{}}",
"category": "Basic",
"creation": "2024-07-10 23:09:39.980242",
"docstatus": 0,
"doctype": "Block Template",
"idx": 0,
"modified": "2024-07-12 09:34:20.763472",
"modified_by": "Administrator",
"name": "Video",
"owner": "Administrator",
"preview": "/builder_assets/Video/video.png",
"template_name": "Video"
}

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions builder/builder/doctype/block_template/block_template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2024, Frappe Technologies Pvt Ltd and contributors
// For license information, please see license.txt

// frappe.ui.form.on("Block Template", {
// refresh(frm) {

// },
// });
71 changes: 71 additions & 0 deletions builder/builder/doctype/block_template/block_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:template_name",
"creation": "2024-07-10 08:51:03.381552",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"template_name",
"block",
"preview",
"category"
],
"fields": [
{
"fieldname": "template_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Template Name",
"reqd": 1,
"unique": 1
},
{
"fieldname": "block",
"fieldtype": "JSON",
"label": "Block",
"reqd": 1
},
{
"fieldname": "preview",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Preview",
"reqd": 1
},
{
"default": "Basic",
"fieldname": "category",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Category",
"options": "Basic\nStructure"
}
],
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-07-10 17:25:15.700195",
"modified_by": "Administrator",
"module": "Builder",
"name": "Block Template",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}
46 changes: 46 additions & 0 deletions builder/builder/doctype/block_template/block_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2024, Frappe Technologies Pvt Ltd and contributors
# For license information, please see license.txt

import os
import shutil

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.modules import scrub
from frappe.modules.export_file import export_to_files

from builder.builder.doctype.builder_page.builder_page import get_template_assets_folder_path


class BlockTemplate(Document):
def on_update(self):
if not self.preview:
frappe.throw(_("Preview Image is mandatory"))

files = frappe.get_all("File", filters={"file_url": self.preview}, fields=["name"])
if files:
_file = frappe.get_doc("File", files[0].name)
assets_folder_path = get_template_assets_folder_path(self)
shutil.copy(_file.get_full_path(), assets_folder_path)
self.preview = f"/builder_assets/{self.name}/{self.preview.split('/')[-1]}"
self.db_set("preview", self.preview)

export_to_files(
record_list=[
[
"Block Template",
self.name,
"builder_block_template",
],
],
record_module="builder",
)

def on_trash(self):
block_template_folder = os.path.join(
frappe.get_app_path("builder"), "builder", "builder_block_template", scrub(self.name)
)
shutil.rmtree(block_template_folder, ignore_errors=True)
assets_folder_path = get_template_assets_folder_path(self)
shutil.rmtree(assets_folder_path, ignore_errors=True)
9 changes: 9 additions & 0 deletions builder/builder/doctype/block_template/test_block_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, Frappe Technologies Pvt Ltd and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestBlockTemplate(FrappeTestCase):
pass
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Copyright (c) 2023, Frappe Technologies Pvt Ltd and contributors
# For license information, please see license.txt

import os

import frappe
from frappe.model.document import Document
import os
from frappe.modules.export_file import export_to_files
from frappe.utils import get_files_path


class BuilderClientScript(Document):
def before_insert(self):
if not self.name:
Expand All @@ -14,12 +17,12 @@ def before_insert(self):

def on_update(self):
self.update_script_file()
self.update_exported_script()

def on_trash(self):
self.delete_script_file()

def update_script_file(self):
script = self.script or ""
script_type = self.script_type or ""
file_name = self.get_file_name_from_url()
file_extension = "js" if script_type == "JavaScript" else "css"
Expand All @@ -46,4 +49,16 @@ def get_file_name_from_url(self):
public_url = self.public_url or ""
if "?" in public_url:
public_url = public_url.split("?")[0]
return public_url.split("/")[-1]
return public_url.split("/")[-1]

def update_exported_script(self):
if not frappe.conf.developer_mode:
return
script_path = os.path.join(
frappe.get_app_path("builder"), "builder", "builder_client_script", self.name
)
if os.path.exists(script_path):
export_to_files(
record_list=[["Builder Client Script", self.name, "builder_client_script"]],
record_module="builder",
)
Loading
Loading