forked from Botanical/BotanJS
Fixed css crashing
This commit is contained in:
@@ -16,8 +16,11 @@ class Resolver:
|
||||
EX_FUNC = "method"
|
||||
EX_CLASS = "class"
|
||||
|
||||
_rLookup = None
|
||||
|
||||
def __init__( self, classMap ):
|
||||
self.classMap = classMap
|
||||
self._rLookup = {}
|
||||
self._reload()
|
||||
|
||||
def _reload( self ):
|
||||
@@ -30,17 +33,23 @@ class Resolver:
|
||||
|
||||
def resource( self, elem ):
|
||||
if "src" in elem.attrib:
|
||||
return {
|
||||
"src": elem.attrib[ "src" ]
|
||||
, "js": elem.attrib[ "js" ]
|
||||
, "css": elem.attrib[ "css" ]
|
||||
}
|
||||
key = elem.attrib[ "src" ]
|
||||
if not key in self._rLookup:
|
||||
self._rLookup[ key ] = {
|
||||
"src": elem.attrib[ "src" ]
|
||||
, "js": elem.attrib[ "js" ]
|
||||
, "css": elem.attrib[ "css" ]
|
||||
}
|
||||
return self._rLookup[ key ]
|
||||
|
||||
parent = self.parentMap[ elem ]
|
||||
|
||||
if parent != None:
|
||||
return self.resource( parent )
|
||||
|
||||
def locate( self, key ):
|
||||
return self._rLookup.get( key )
|
||||
|
||||
def resolve( self, c, classList ):
|
||||
self.resolved = []
|
||||
self.__resolve( c, classList )
|
||||
@@ -161,27 +170,23 @@ class BotanClassResolver:
|
||||
|
||||
for cdef in classList:
|
||||
f = cdef[ "src" ]
|
||||
possibleList = []
|
||||
|
||||
cssFile = os.path.splitext( f )[0] + ".css"
|
||||
|
||||
if cssFile not in possibleList:
|
||||
possibleList.append( cssFile )
|
||||
if not cdef[ "css" ] == "1":
|
||||
cssList.append( cdef )
|
||||
|
||||
f = f.split( PY_SEP )
|
||||
l = len( f )
|
||||
|
||||
for i in range( 1, l ):
|
||||
cssFile = PY_SEP.join( x for x in f[:-i] ) + PY_SEP + "@_this.css"
|
||||
if cssFile not in possibleList:
|
||||
possibleList.append( cssFile )
|
||||
key = PY_SEP.join( x for x in f[:-i] ) + PY_SEP + "_this.js"
|
||||
_def = self.resv.locate( key )
|
||||
|
||||
possibleList.sort()
|
||||
if _def and not _def[ "css" ] == "1":
|
||||
cssList.append( _def )
|
||||
|
||||
for f in possibleList:
|
||||
f = f.replace( "@_this.css", "_this.css" )
|
||||
if os.path.exists( os.path.join( self.R, f ) ):
|
||||
cssList.append( f )
|
||||
cssList.sort( key = lambda x : x[ "src" ] )
|
||||
|
||||
|
||||
def getCache( self, fileList, cName, mode ):
|
||||
@@ -229,7 +234,6 @@ class BotanClassResolver:
|
||||
# The root file
|
||||
outputJs = self.BotanFile( "_this.js" )
|
||||
|
||||
|
||||
for f in cList:
|
||||
f = f[ "src" ]
|
||||
path = (
|
||||
@@ -277,7 +281,7 @@ class BotanClassResolver:
|
||||
outputCss = struct + self.BotanFile( "_this.css" )
|
||||
|
||||
for f in self.cleanList( cList ):
|
||||
outputCss += self.BotanFile( f )
|
||||
outputCss += self.BotanFile( f["src"][:-2] + "css" )
|
||||
|
||||
self.JWork.saveCache( os.path.join( self.CR, md5[0] ), outputCss, "css" )
|
||||
|
||||
|
Reference in New Issue
Block a user