diff --git a/Dockerfile b/Dockerfile index f99286c1..3743b313 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,16 +10,15 @@ RUN chown www-data:www-data . -R RUN pip3 install Flask redis compressinja Celery -COPY . /app/ - ADD [ "https://github.com/tgckpg/BotanJS/releases/download/compressors/closure.jar" \ , "https://github.com/tgckpg/BotanJS/releases/download/compressors/yuicompressor.jar" \ , "/opt/utils/" ] RUN chmod 644 /opt/utils/*.jar +COPY . /app/ + USER www-data EXPOSE 5000 ENTRYPOINT ["setup/docker.start"] - diff --git a/botanjs/config.py b/botanjs/config.py index 21173516..6daa295d 100644 --- a/botanjs/config.py +++ b/botanjs/config.py @@ -1,7 +1,15 @@ #!/usr/bin/env python3 -import configparser +import configparser, os Config = configparser.ConfigParser( interpolation = configparser.ExtendedInterpolation() ) Config.read( "settings.ini" ) -DEBUG = Config[ "Env" ][ "Debug" ] +DEBUG = os.getenv( "DEBUG" ) +if DEBUG is None: + DEBUG = Config[ "Env" ][ "Debug" ] +else: + Config[ "Env" ][ "Debug" ] = DEBUG + +REDIS_CONN = os.getenv( "REDIS_CONN" ) +if not REDIS_CONN is None: + Config[ "Redis" ][ "ConnStr" ] = REDIS_CONN diff --git a/botanjs/service/jclassresv.py b/botanjs/service/jclassresv.py index 6989a41f..0bca229b 100644 --- a/botanjs/service/jclassresv.py +++ b/botanjs/service/jclassresv.py @@ -285,7 +285,8 @@ class BotanClassResolver: if cacheFile != None: return cacheFile; - outputCss = "" + # The root file + outputCss = self.BotanFile( "_this.css" ) for f in self.cleanList( cList ): outputCss += self.BotanFile( f ) diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.css b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.css index e4c92dff..5ede39ef 100644 --- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.css +++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.css @@ -49,7 +49,7 @@ } textarea.v_snippet_input { - font-family: monospace; + font-family: site-mono; font-size: 1em; } diff --git a/botanjs/src/Astro/Blog/Components/Album.css b/botanjs/src/Astro/Blog/Components/Album.css index 1e026c1f..5157e65b 100644 --- a/botanjs/src/Astro/Blog/Components/Album.css +++ b/botanjs/src/Astro/Blog/Components/Album.css @@ -1,14 +1,14 @@ -.site_file[data-type="album"] { +.site-file[data-type="album"] { column-width: 225px; column-gap: 0.75em; } -.site_file[data-type="album"] > div { +.site-file[data-type="album"] > div { display: inline-block; margin-bottom: 0.5em; width: 100%; } -.site_file[data-type="album"] > div img { +.site-file[data-type="album"] > div img { width: 100%; } diff --git a/botanjs/src/Astro/Blog/Components/Album.js b/botanjs/src/Astro/Blog/Components/Album.js index a37360de..f783950d 100644 --- a/botanjs/src/Astro/Blog/Components/Album.js +++ b/botanjs/src/Astro/Blog/Components/Album.js @@ -64,11 +64,9 @@ Cycle.next( function() { - new SiteFile( this.id, this.hash ); - }.bind({ id: uuid, hash: file.hash }) ); + new SiteFile( this.id, this.info.hash, this.info ); + }.bind({ id: uuid, info: file }) ); } - - console.log( finfo ); }; var loadFailed = function( obj ) diff --git a/botanjs/src/Astro/Blog/Components/Entry/Blog.css b/botanjs/src/Astro/Blog/Components/Entry/Blog.css index a9d32866..a6303391 100644 --- a/botanjs/src/Astro/Blog/Components/Entry/Blog.css +++ b/botanjs/src/Astro/Blog/Components/Entry/Blog.css @@ -4,7 +4,7 @@ } .inline-code { - font-family: monospace; + font-family: site-mono; font-size: 1.12em; color: black; diff --git a/botanjs/src/Astro/Blog/Components/SiteFile.js b/botanjs/src/Astro/Blog/Components/SiteFile.js index 555dd466..12c3c800 100644 --- a/botanjs/src/Astro/Blog/Components/SiteFile.js +++ b/botanjs/src/Astro/Blog/Components/SiteFile.js @@ -20,7 +20,7 @@ /** @type {_AstConf_.SiteFile} */ var config = null; - var SiteFile = function ( id, hash ) + var SiteFile = function ( id, hash, nObj ) { if( !config ) throw new Error( "config is not defined" ); // TODO: Make a trigger for downloading from server @@ -38,9 +38,14 @@ if( stage.getAttribute( "noauto" ) != null ) return this; var applyStructure = function( obj ) + { + return _applyStructure( JSON.parse( obj ).file ); + }; + + var _applyStructure = function( obj ) { /** @type {_AstJson_.SiteFile} */ - var finfo = JSON.parse( obj ).file; + var finfo = obj; switch( finfo.type ) { @@ -50,16 +55,16 @@ switch( IDOMElement(stage).getDAttribute('size') ) { case "small": - node.src = config.path.image.small + hash + '.jpg'; + node.src = finfo.thumbs.small || ( config.path.image.small + hash + '.jpg' ); break; case "medium": - node.src = config.path.image.medium + hash + '.jpg'; + node.src = finfo.thumbs.medium || ( config.path.image.medium + hash + '.jpg' ); break; case "original": node.src = config.path.image.original + hash + '.jpg'; break; default: // large - node.src = config.path.image.large + hash + '.jpg'; + node.src = finfo.thumbs.large || ( config.path.image.large + hash + '.jpg' ); } stage.appendChild(Dand.wrapne( @@ -134,7 +139,14 @@ stage.appendChild( Dand.wrapc( "sf_failed", Dand.textNode( "Error: Failed to get resources info" ) ) ); }; - this.loadInfo( applyStructure, loadFailed ); + if( nObj ) + { + _applyStructure( nObj ); + } + else + { + this.loadInfo( applyStructure, loadFailed ); + } }; SiteFile.prototype.loadInfo = function( success, failed ) diff --git a/botanjs/src/Astro/Bootstrap.css b/botanjs/src/Astro/Bootstrap.css index e0c7d436..2cfacc67 100644 --- a/botanjs/src/Astro/Bootstrap.css +++ b/botanjs/src/Astro/Bootstrap.css @@ -40,7 +40,7 @@ /*{{{ Global Element Styles */ pre { - font-family: monospace; + font-family: site-mono; } textarea, input, div[contentEditable="true"], select { diff --git a/botanjs/src/Astro/Build/Components/BuildList.css b/botanjs/src/Astro/Build/Components/BuildList.css index 1cf92014..ba5d28e5 100644 --- a/botanjs/src/Astro/Build/Components/BuildList.css +++ b/botanjs/src/Astro/Build/Components/BuildList.css @@ -1,5 +1,5 @@ .build-list > a { - font-family: monospace; + font-family: site-mono; display: block; diff --git a/botanjs/src/Astro/Build/Components/BuildReport.css b/botanjs/src/Astro/Build/Components/BuildReport.css index 97984dfc..1c1afe3a 100644 --- a/botanjs/src/Astro/Build/Components/BuildReport.css +++ b/botanjs/src/Astro/Build/Components/BuildReport.css @@ -21,7 +21,7 @@ .build-status > * .failed { color: darkred; } .build-commit-message { - font-family: monospace; + font-family: site-mono; padding: 0.2em 0; } diff --git a/botanjs/src/Astro/Build/Page/Index.css b/botanjs/src/Astro/Build/Page/Index.css index 6e7945fe..af4dfb75 100644 --- a/botanjs/src/Astro/Build/Page/Index.css +++ b/botanjs/src/Astro/Build/Page/Index.css @@ -1,9 +1,9 @@ -.site-news { font-family: monospace; } +.site-news { font-family: site-mono; } .site-news > span { display: block; } .rbuilds > a { display: block; - font-family: monospace; + font-family: site-mono; } .rbuilds > a > span { padding: 0 0.5em; diff --git a/botanjs/src/Astro/Penguin/Layout/MainFrame.css b/botanjs/src/Astro/Penguin/Layout/MainFrame.css index edafead2..8bfb117d 100644 --- a/botanjs/src/Astro/Penguin/Layout/MainFrame.css +++ b/botanjs/src/Astro/Penguin/Layout/MainFrame.css @@ -7,7 +7,7 @@ body { font-family: custom-sans,Helvetica,Arial,STHeiti,"Microsoft JhengHei","微軟正黑體"; } -pre { font-family: monospace; } +pre { font-family: site-mono; } ::selection { color: white; @@ -32,7 +32,7 @@ a { } textarea { - font-family: monospace; + font-family: site-mono; } sup { vertical-align: super; } diff --git a/botanjs/src/Astro/Penguin/Page/Docs.css b/botanjs/src/Astro/Penguin/Page/Docs.css index b02f7021..3f0320a7 100644 --- a/botanjs/src/Astro/Penguin/Page/Docs.css +++ b/botanjs/src/Astro/Penguin/Page/Docs.css @@ -1,5 +1,5 @@ h4 { font-family: custom-sans; } -h5, h6 { font-family: monospace; } +h5, h6 { font-family: site-mono; } h4 { font-size: 1.5em; } h5 { font-size: 1.3em; } h6 { font-size: 1.1em; } diff --git a/botanjs/src/Astro/Starfall/Layout/MainFrame.css b/botanjs/src/Astro/Starfall/Layout/MainFrame.css index 5e1936b2..7bd232bb 100644 --- a/botanjs/src/Astro/Starfall/Layout/MainFrame.css +++ b/botanjs/src/Astro/Starfall/Layout/MainFrame.css @@ -7,7 +7,7 @@ body { font-family: custom-sans,Helvetica,Arial,STHeiti,"Microsoft JhengHei","微軟正黑體"; } -pre { font-family: monospace; } +pre { font-family: site-mono; } ::selection { color: white; diff --git a/botanjs/src/Components/Console.css b/botanjs/src/Components/Console.css index 625abb92..a50418e1 100644 --- a/botanjs/src/Components/Console.css +++ b/botanjs/src/Components/Console.css @@ -8,7 +8,7 @@ .dbg_lastMsg { float: left; - font-family: monospace; + font-family: site-mono; color: #AAA; font-size: 1em; @@ -67,5 +67,5 @@ outline: none; border: none; - font-family: monospace; + font-family: site-mono; } diff --git a/botanjs/src/_this.css b/botanjs/src/_this.css new file mode 100644 index 00000000..38e417ec --- /dev/null +++ b/botanjs/src/_this.css @@ -0,0 +1,8 @@ +@font-face{ + font-family: site-mono; + src: local("Consolas"), + local("Bitstream Vera Sans Mono"), + local("Courier New"), + local("Courier"), + local("monospace"); +} diff --git a/botanjs/src/externs/_AstJson_.SiteFile.js b/botanjs/src/externs/_AstJson_.SiteFile.js index 0cfbb04b..19a329e7 100644 --- a/botanjs/src/externs/_AstJson_.SiteFile.js +++ b/botanjs/src/externs/_AstJson_.SiteFile.js @@ -19,3 +19,11 @@ _AstJson_.SiteFile.file; _AstJson_.SiteFile.file.type; /** @type {String} */ _AstJson_.SiteFile.file.src_location; + /** @type {Object} */ + _AstConf_.SiteFile.thumbes; + /** @type {String} */ + _AstConf_.SiteFile.thumbs.small; + /** @type {String} */ + _AstConf_.SiteFile.thumbs.medium; + /** @type {String} */ + _AstConf_.SiteFile.thumbs.large; diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml index 19b250f3..d98c8697 100644 --- a/k8s/deployments.yaml +++ b/k8s/deployments.yaml @@ -26,7 +26,7 @@ spec: mountPath: "/app/cache" containers: - name: web - image: registry.k8s.astropenguin.net/astrojs:2022.04.05 + image: registry.k8s.astropenguin.net/astrojs:2022.04.05.03 securityContext: runAsGroup: 1001 runAsNonRoot: true @@ -50,7 +50,7 @@ spec: - name: redis image: redis:6.0.8-alpine - name: compiler - image: registry.k8s.astropenguin.net/astrojs:2022.04.05 + image: registry.k8s.astropenguin.net/astrojs:2022.04.05.03 securityContext: runAsGroup: 1001 runAsNonRoot: true diff --git a/settings.ini b/settings.ini index ab9f7d0e..ee0ab29c 100644 --- a/settings.ini +++ b/settings.ini @@ -5,6 +5,9 @@ Port = 5000 [Env] Debug = False +[Redis] +ConnStr = redis://:@localhost:6379/9 + [Paths] Runtime = ${SiteRoot} Log = ${SiteRoot}/logs @@ -13,7 +16,7 @@ Cache = ${SiteRoot}/cache [BotanJS] SrcDir = ${Paths:Runtime}/botanjs/src -CeleryBroker = redis://:@localhost:6379/9 +CeleryBroker = ${Redis:ConnStr} ClosureCompiler = /opt/utils/closure.jar YuiCompressor = /opt/utils/yuicompressor.jar diff --git a/windows/app/Dockerfile b/windows/app/Dockerfile index 0fe3578d..3ae5cc7d 100644 --- a/windows/app/Dockerfile +++ b/windows/app/Dockerfile @@ -2,11 +2,13 @@ FROM astrojs/jre-nanoserver-20h2:latest RUN pip3 install Flask redis compressinja celery -RUN New-Item -ItemType "Directory" -Path /opt/utils; \ - New-Item -ItemType "Directory" -Path /app; \ +RUN New-Item -ItemType Directory -Path /opt/utils; \ + New-Item -ItemType Directory -Path /app/cache -Force; \ [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; \ Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/tgckpg/BotanJS/releases/download/compressors/closure.jar' -OutFile '/opt/utils/closure.jar' ; \ Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/tgckpg/BotanJS/releases/download/compressors/yuicompressor.jar' -OutFile '/opt/utils/yuicompressor.jar' ; -EXPOSE 5000 +COPY . /app WORKDIR /app + +EXPOSE 5000 diff --git a/windows/base-compose.yml b/windows/base-compose.yml new file mode 100644 index 00000000..cb2fa41e --- /dev/null +++ b/windows/base-compose.yml @@ -0,0 +1,9 @@ +version: '3.9' + +services: + python: + build: pyrt + image: astrojs/pyrt-nanoserver-20h2 + jre: + build: jre + image: astrojs/jre-nanoserver-20h2 diff --git a/windows/docker-compose.yml b/windows/docker-compose.yml index 7149d262..2426b8ec 100644 --- a/windows/docker-compose.yml +++ b/windows/docker-compose.yml @@ -1,12 +1,6 @@ version: '3.9' services: - python: - build: pyrt - image: astrojs/pyrt-nanoserver-20h2 - jre: - build: jre - image: astrojs/jre-nanoserver-20h2 redis: container_name: astrojsdev_redis build: redis @@ -17,23 +11,25 @@ services: build: context: ../ dockerfile: windows/app/Dockerfile + environment: + REDIS_CONN: redis://:@redis:6379/9 command: [ "python", "main.py" ] # [ "ping", "127.0.0.1", "-n", "9999" ] depends_on: - redis ports: - 5000:5000 volumes: - - ../:C:/app + - cache:C:/app/cache tasks: container_name: astrojsdev_compiler image: astrojs/app + environment: + REDIS_CONN: redis://:@redis:6379/9 command: [ "celery", "-A", "botanjs.service.jwork", "worker", "-l", "info", "--pool=solo" ] depends_on: - redis - web volumes: - - ../:C:/app - + - cache:C:/app/cache volumes: cache: - temp: