Fixed preferred not working for SiteFile snippet

This commit is contained in:
斟酌 鵬兄 2024-11-14 15:25:28 +08:00
parent 89e990c194
commit 32884c3b7c
7 changed files with 28 additions and 15 deletions

View File

@ -1,10 +1,14 @@
#!/usr/bin/env python3
import os, re, sys import os, re, sys
from xml.dom import minidom from xml.dom import minidom
from collections import defaultdict 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""" RegEx_N = re.compile( r"""
.* .*
@ -198,4 +202,3 @@ class ClassMap:
classFile = classFile.replace( self.R + os.path.sep, "" ) classFile = classFile.replace( self.R + os.path.sep, "" )
self.drawMap( ns, ci, ce, classFile, chksum ) self.drawMap( ns, ci, ce, classFile, chksum )
return self.DOM.toxml() return self.DOM.toxml()

View File

@ -6,7 +6,7 @@ Config.read( "settings.ini" )
DEBUG = os.getenv( "DEBUG" ) DEBUG = os.getenv( "DEBUG" )
if DEBUG is None: if DEBUG is None:
DEBUG = Config[ "Env" ][ "Debug" ] DEBUG = Config.getboolean( "Env", "Debug" )
else: else:
Config[ "Env" ][ "Debug" ] = str( DEBUG == "1" ) Config[ "Env" ][ "Debug" ] = str( DEBUG == "1" )

View File

@ -22,6 +22,13 @@
position: relative; 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 { .asl_header {
width: 100%; width: 100%;
height: 20px; height: 20px;

View File

@ -416,7 +416,7 @@
, insertCollection = function() { , insertCollection = function() {
var collections = [] var collections = []
, ul = Dand.wrapc( "canvasGeneral", null, new IKey( "style", "color: #BBB;" ) ) , ul = Dand.wrapc( "canvasGeneral asl_colls" )
; ;
// Get current albums to list // Get current albums to list
@ -430,8 +430,8 @@
, li = Dand.wrap( , li = Dand.wrap(
null, "g_item" + Perf.uuid, null null, "g_item" + Perf.uuid, null
, [ , [
Dand.wrapne("span", t.getDAttribute("title"), new IKey("style", "width: 75%;")) Dand.wrap("span", null, "c75", t.getDAttribute("title") )
, Dand.wrapne("span", t.getDAttribute("author"), new IKey("style", "width: 25%;")) , Dand.wrap("span", null, "c25", t.getDAttribute("author") )
] ]
, new DataKey("id", t.getDAttribute("id")) , new DataKey("id", t.getDAttribute("id"))
); );

View File

@ -0,0 +1,3 @@
.v_box.sf-view {
max-height: 150px;
}

View File

@ -59,7 +59,7 @@
, "OK", "Cancel" , "OK", "Cancel"
, visualizer.bind({ , visualizer.bind({
code: v_snippetInput code: v_snippetInput
, preferred: input_preferred , input_preferred: input_preferred
, stage: this._stage , stage: this._stage
}) })
).show(); ).show();
@ -181,18 +181,17 @@
, visualizer = function ( submitted, override ) , visualizer = function ( submitted, override )
{ {
var hash, _obj, stage = this.stage; var hash, _obj, stage = this.stage;
if( override ) if( override )
{ {
hash = override.value; hash = override.value;
preferred = override.preferred ? "on" : ""; preferred = override[ "preferred" ] ? "on" : "";
} }
else else
{ {
hash = this.code.value; hash = this.code.value;
preferred = this.preferred.checked ? "on" : ""; preferred = this.input_preferred.checked ? "on" : "";
} }
_obj = { file: hash }; _obj = { file: hash };
@ -202,7 +201,7 @@
// Visualize component // Visualize component
if (!stage) if (!stage)
{ {
temp = Dand.wrapc("v_box" temp = Dand.wrapc("v_box sf-view"
, [ , [
Dand.wrape("Getting information from Server ...") Dand.wrape("Getting information from Server ...")
, Dand.wrapc("v_description", "Site file (hash): " + hash) , Dand.wrapc("v_description", "Site file (hash): " + hash)
@ -210,7 +209,6 @@
, [ , [
new DataKey( "value", hash ) new DataKey( "value", hash )
, new DataKey( "size", ( override && override.size ) || "large" ) , new DataKey( "size", ( override && override.size ) || "large" )
, new IKey( "style", "max-height: 150px;" )
, new DataKey( "preferred", preferred ) , new DataKey( "preferred", preferred )
] ]
); );

View File

@ -2,9 +2,11 @@ from functools import lru_cache
from zlib import adler32 as _HashFunc from zlib import adler32 as _HashFunc
HashFunc = lambda v: hex( _HashFunc( v ) )[2:] HashFunc = lambda v: hex( _HashFunc( v ) )[2:]
@lru_cache( maxsize = 1024 ) @lru_cache( maxsize = 1024 )
def checksum( file_path ): def checksum( file_path ):
return checksum_r( file_path )
def checksum_r( file_path ):
try: try:
with open( file_path, "rb" ) as f: with open( file_path, "rb" ) as f:
return HashFunc( f.read() ) return HashFunc( f.read() )