fix: Rename fields and cleanup
This commit is contained in:
parent
75065ff210
commit
031b6cfd44
4 changed files with 59 additions and 15 deletions
|
|
@ -25,8 +25,8 @@
|
|||
{{ head_html or "" }}
|
||||
{%- endif %}
|
||||
|
||||
{% if theme.css_file_url %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ theme.css_file_url }}">
|
||||
{% if theme.apply_custom_theme and theme.custom_theme_url %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ theme.custom_theme_url }}">
|
||||
{% else %}
|
||||
<link type="text/css" rel="stylesheet" href="/assets/css/frappe-web-b4.css">
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -948,7 +948,40 @@
|
|||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "customize_bootstrap_4",
|
||||
"fieldname": "apply_custom_theme",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Apply Custom Theme",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "apply_custom_theme",
|
||||
"fieldname": "custom_theme",
|
||||
"fieldtype": "Code",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
|
|
@ -957,7 +990,7 @@
|
|||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Customize Bootstrap 4",
|
||||
"label": "Custom Theme",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "SCSS",
|
||||
|
|
@ -981,8 +1014,9 @@
|
|||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "css_file_url",
|
||||
"fieldtype": "Data",
|
||||
"depends_on": "apply_custom_theme",
|
||||
"fieldname": "custom_theme_url",
|
||||
"fieldtype": "Read Only",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
|
|
@ -990,7 +1024,7 @@
|
|||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "CSS File URL",
|
||||
"label": "Custom Theme URL",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
|
|
@ -1017,7 +1051,7 @@
|
|||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-27 16:43:58.160802",
|
||||
"modified": "2019-01-30 15:48:12.196916",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Website Theme",
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ class WebsiteTheme(Document):
|
|||
frappe.throw(_("Top Bar Color and Text Color are the same. They should be have good contrast to be readable."))
|
||||
|
||||
def validate_custom_bootstrap_theme(self):
|
||||
if self.customize_bootstrap_4:
|
||||
if self.apply_custom_theme and self.custom_theme:
|
||||
doc_before_save = self.get_doc_before_save()
|
||||
if self.customize_bootstrap_4 != doc_before_save.customize_bootstrap_4:
|
||||
if self.custom_theme != doc_before_save.custom_theme:
|
||||
self.generate_bootstrap_theme()
|
||||
|
||||
def export_doc(self):
|
||||
|
|
@ -59,13 +59,22 @@ class WebsiteTheme(Document):
|
|||
website_settings.clear_cache()
|
||||
|
||||
def generate_bootstrap_theme(self):
|
||||
from frappe.commands import popen
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
file_name = frappe.scrub(self.name) + '.css'
|
||||
content = self.customize_bootstrap_4
|
||||
content = self.custom_theme
|
||||
content = content.replace('\n', '\\n')
|
||||
command = ['node', 'generate_bootstrap_theme.js', file_name, content]
|
||||
popen(command, cwd=frappe.get_app_path('frappe', '..'), shell=False)
|
||||
self.css_file_url = '/assets/frappe/website_theme/' + file_name
|
||||
|
||||
process = Popen(command, cwd=frappe.get_app_path('frappe', '..'), stdout=PIPE, stderr=PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
if stderr:
|
||||
frappe.throw('<pre>{stderr}</pre>'.format(stderr=stderr))
|
||||
else:
|
||||
self.custom_theme_url = '/assets/frappe/website_theme/' + file_name
|
||||
|
||||
frappe.msgprint(_('Compiled Successfully'), alert=True)
|
||||
|
||||
def use_theme(self):
|
||||
use_theme(self.name)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const node_modules_path = path.resolve(get_public_path('frappe'), 'node_modules'
|
|||
const scss_path = path.resolve(get_public_path('frappe'), 'scss');
|
||||
const website_theme_path = path.resolve(get_public_path('frappe'), 'website_theme');
|
||||
const custom_theme_name = process.argv[2];
|
||||
|
||||
let scss_content = process.argv[3];
|
||||
scss_content = scss_content.replace(/\\n/g, '\n');
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ sass.render({
|
|||
}
|
||||
}, function(err, result) {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
console.error(err.formatted)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue