forked from Botanical/BotanJS
Fixed preferred not working for SiteFile snippet
This commit is contained in:
parent
89e990c194
commit
32884c3b7c
@ -1,9 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, re, sys
|
||||
|
||||
from xml.dom import minidom
|
||||
from collections import defaultdict
|
||||
|
||||
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()
|
||||
|
||||
|
@ -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" )
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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"))
|
||||
);
|
||||
|
@ -0,0 +1,3 @@
|
||||
.v_box.sf-view {
|
||||
max-height: 150px;
|
||||
}
|
@ -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 )
|
||||
]
|
||||
);
|
||||
|
@ -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() )
|
||||
|
Loading…
Reference in New Issue
Block a user