from webmagic.untwist import ( ResponseCacheOptions, CookieInstaller, BetterResource, BetterFile, ConnectionTrackingSite) import googstyle try: from brequire import requireFile, requireFiles except ImportError: requireFile = requireFiles = lambda _: None requireFiles([f.path for f in FilePath(googstyle.__file__).sibling('goog-images').children()]) requireFile(FilePath(__file__).sibling('index.html').path) requireFiles([f.path for f in FilePath(__file__).sibling('static').child('thumbnails').children()]) class DemosMinervaRoot(BetterResource): def __init__(self, webPort, fileCache, mainSocketPort, domain, closureLibrary): import coreweb import minerva import demosminerva import js_coreweb import js_minerva import js_demosminerva BetterResource.__init__(self)
from twisted.python import log from twisted.python.filepath import FilePath from webmagic.untwist import BetterResource from minerva.mutils import ( MinervaBootstrap, strictSecureDecodeJson, StrictDecodeError) try: from brequire import requireFile, requireFiles except ImportError: requireFile = requireFiles = lambda _: None requireFile(FilePath(__file__).sibling('whiteboard.html').path) requireFiles([f.path for f in FilePath(__file__).sibling('static').children() if not f.isdir()]) class WhiteboardResource(BetterResource): templateFile = FilePath(__file__).sibling('whiteboard.html') dictionary = {'dev_mode': False} def __init__(self, fileCache, mainSocketPort, domain, responseCacheOptions): BetterResource.__init__(self) self.putChild('', MinervaBootstrap(fileCache, self.templateFile, dict(domain=domain, mainSocketPort=mainSocketPort, **self.dictionary)))
def _getLatestProtocol(self): try: return self.protos[-1] except IndexError: raise NoProtocol() def abortLatestProtocol(self): latestTransport = self._getLatestProtocol().transport if hasattr(latestTransport, "abortConnection"): latestTransport.abortConnection() else: latestTransport.loseConnection() requireFile(FilePath(__file__).sibling("ljstream.html").path) requireFiles([f.path for f in FilePath(__file__).sibling("static").children() if not f.isdir()]) class LjStreamResource(BetterResource): templateFile = FilePath(__file__).sibling("ljstream.html") dictionary = {"dev_mode": False} def __init__(self, fileCache, mainSocketPort, domain, responseCacheOptions): BetterResource.__init__(self) self.putChild( "", MinervaBootstrap( fileCache, self.templateFile, dict(domain=domain, mainSocketPort=mainSocketPort, **self.dictionary) ),