penguin/AstroJS

Javascript framework for my blog

commit 32884c3b7c4e100c61284151eed0ff86596e0492

author斟酌 鵬兄 <tgckpg@gmail.com>
date2024-11-14T07:25:28Z
subjectFixed preferred not working for SiteFile snippet
commit 32884c3b7c4e100c61284151eed0ff86596e0492
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2024-11-14T07:25:28Z

    Fixed preferred not working for SiteFile snippet
---
 botanjs/classmap.py                                           | 11 +++++++----
 botanjs/config.py                                             |  2 +-
 botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.css              |  7 +++++++
 botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.js               |  6 +++---
 .../src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.css  |  3 +++
 .../src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.js   | 10 ++++------
 botanjs/utils.py                                              |  4 +++-
 7 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/botanjs/classmap.py b/botanjs/classmap.py
index 2902d7f..f41555d 100644
--- a/botanjs/classmap.py
+++ b/botanjs/classmap.py
@@ -1,10 +1,14 @@
-#!/usr/bin/env python3
-
 import os, re, sys
 
 from xml.dom import minidom
 from collections import defaultdict
-from botanjs.utils import checksum
+
+from botanjs.config import DEBUG
+
+if DEBUG:
+	from botanjs.utils import checksum_r as checksum
+else:
+	from botanjs.utils import checksum
 
 RegEx_N = re.compile( r"""
 		.*
@@ -198,4 +202,3 @@ class ClassMap:
 				classFile = classFile.replace( self.R + os.path.sep, "" )
 				self.drawMap( ns, ci, ce, classFile, chksum )
 		return self.DOM.toxml()
-
diff --git a/botanjs/config.py b/botanjs/config.py
index 4582157..6ce5794 100644
--- a/botanjs/config.py
+++ b/botanjs/config.py
@@ -6,7 +6,7 @@ Config.read( "settings.ini" )
 
 DEBUG = os.getenv( "DEBUG" )
 if DEBUG is None:
-	DEBUG = Config[ "Env" ][ "Debug" ]
+	DEBUG = Config.getboolean( "Env", "Debug" )
 else:
 	Config[ "Env" ][ "Debug" ] = str( DEBUG == "1" )
 
diff --git a/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.css b/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.css
index af8c58b..caa268e 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.css
+++ b/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.css
@@ -22,6 +22,13 @@
 	position: relative;
 }
 
+.asl_colls.canvasGeneral {
+	color: #BBB;
+}
+
+.canvasGeneral.asl_colls > div > span.c75 { width: 75%; }
+.canvasGeneral.asl_colls > div > span.c25 { width: 25%; }
+
 .asl_header {
 	width: 100%;
 	height: 20px;
diff --git a/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.js b/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.js
index dbd8be8..9e5d17b 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/SiteLibrary.js
@@ -416,7 +416,7 @@
 
 			, insertCollection = function() {
 				var collections = []
-					, ul = Dand.wrapc( "canvasGeneral", null, new IKey( "style", "color: #BBB;" ) )
+					, ul = Dand.wrapc( "canvasGeneral asl_colls" )
 				;
 
 				// Get current albums to list
@@ -430,8 +430,8 @@
 						, li = Dand.wrap(
 							null, "g_item" + Perf.uuid, null
 							, [
-								Dand.wrapne("span", t.getDAttribute("title"), new IKey("style", "width: 75%;"))
-								, Dand.wrapne("span", t.getDAttribute("author"), new IKey("style", "width: 25%;"))
+								Dand.wrap("span", null, "c75", t.getDAttribute("title") )
+								, Dand.wrap("span", null, "c25", t.getDAttribute("author") )
 							]
 							, new DataKey("id", t.getDAttribute("id"))
 						);
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.css b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.css
new file mode 100644
index 0000000..23921f1
--- /dev/null
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.css
@@ -0,0 +1,3 @@
+.v_box.sf-view {
+	max-height: 150px;
+}
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.js
index 8527f1f..1b75000 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/SiteFile.js
@@ -59,7 +59,7 @@
 				, "OK", "Cancel"
 				, visualizer.bind({
 					code: v_snippetInput
-					, preferred: input_preferred
+					, input_preferred: input_preferred
 					, stage: this._stage
 				})
 			).show();
@@ -181,18 +181,17 @@
 
 		, visualizer = function ( submitted, override )
 		{
-
 			var hash, _obj, stage = this.stage;
 
 			if( override )
 			{
 				hash = override.value;
-				preferred = override.preferred ? "on" : "";
+				preferred = override[ "preferred" ] ? "on" : "";
 			}
 			else
 			{
 				hash = this.code.value;
-				preferred = this.preferred.checked ? "on" : "";
+				preferred = this.input_preferred.checked ? "on" : "";
 			}
 
 			_obj = { file: hash };
@@ -202,7 +201,7 @@
 				// Visualize component
 				if (!stage)
 				{
-					temp =  Dand.wrapc("v_box"
+					temp =  Dand.wrapc("v_box sf-view"
 						, [
 							Dand.wrape("Getting information from Server ...")
 							, Dand.wrapc("v_description", "Site file (hash): " + hash)
@@ -210,7 +209,6 @@
 						, [
 							new DataKey( "value", hash )
 							, new DataKey( "size", ( override && override.size ) || "large" )
-							, new IKey( "style", "max-height: 150px;" )
 							, new DataKey( "preferred", preferred )
 						]
 					);
diff --git a/botanjs/utils.py b/botanjs/utils.py
index 07bef39..ab6d760 100644
--- a/botanjs/utils.py
+++ b/botanjs/utils.py
@@ -2,9 +2,11 @@ from functools import lru_cache
 from zlib import adler32 as _HashFunc
 HashFunc = lambda v: hex( _HashFunc( v ) )[2:]
 
-
 @lru_cache( maxsize = 1024 )
 def checksum( file_path ):
+	return checksum_r( file_path )
+
+def checksum_r( file_path ):
 	try:
 		with open( file_path, "rb" ) as f:
 			return HashFunc( f.read() )