Skip to content

Commit

Permalink
blockly plugin: load language in blockly based on shng language
Browse files Browse the repository at this point in the history
  • Loading branch information
onkelandy committed Oct 25, 2023
1 parent 2bdebac commit 40ad403
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion blockly/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ def index_html(self, cmd='', filename='', logicname='', v=0):
self.logic_filename = filename
self.logicname = logicname
self.logger.info("index_html: self.logicname = '{}', self.logic_filename = '{}'".format(self.logicname, self.logic_filename))
language = self._sh.get_defaultlanguage()

tmpl = self.tplenv.get_template('blockly.html')
return tmpl.render(smarthome=self._sh,
p=self.plugin,
dyn_sh_toolbox=self._DynToolbox(self._sh),
cmd=self.cmd,
logicname=logicname,
lang=language,
timestamp=str(time.time()))


Expand Down Expand Up @@ -148,14 +150,15 @@ def edit_html(self, cmd='', filename='', logicname='', v=0):
self.logic_filename = filename
self.logicname = logicname
self.logger.info("edit_html: self.logicname = '{}', self.logic_filename = '{}'".format(self.logicname, self.logic_filename))

language = self._sh.get_defaultlanguage()

tmpl = self.tplenv.get_template('blockly.html')
return tmpl.render(smarthome=self._sh,
p=self.plugin,
dyn_sh_toolbox=self._DynToolbox(self._sh),
cmd=self.cmd,
logicname=logicname,
lang=language,
timestamp=str(time.time()))


Expand Down
2 changes: 1 addition & 1 deletion blockly/webif/static/js/logics_blockly_code.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* Create a namespace for the application.
*/
Expand Down Expand Up @@ -74,7 +75,6 @@ Code.saveBlocks = function() {
if (topblock.data == "sh_logic_main") {
logicname = Code.workspace.getTopBlocks()[0].getFieldValue('LOGIC_NAME')
};
//Code.workspace;
var pycode = Blockly.Python.workspaceToCode(Code.workspace);
var xmldom = Blockly.Xml.workspaceToDom(Code.workspace);
var xmltxt = Blockly.utils.xml.domToText(xmldom);
Expand Down

0 comments on commit 40ad403

Please sign in to comment.