commit 5acc48289c733fe78200d91165f542609991f510
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2022-04-05T11:00:42Z |
| subject | Added RespH Snippet |
commit 5acc48289c733fe78200d91165f542609991f510
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2022-04-05T11:00:42Z
Added RespH Snippet
---
Dockerfile | 6 +-
.../Blog/AstroEdit/Visualizer/Snippet/Meta.js | 6 --
.../Blog/AstroEdit/Visualizer/Snippet/RespH.js | 99 ++++++++++++++++++++++
.../src/Astro/Blog/AstroEdit/Visualizer/_this.js | 1 +
k8s/deployments.yaml | 4 +-
5 files changed, 105 insertions(+), 11 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 3743b31..243f2fc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,6 @@ RUN mkdir -p /opt/utils
RUN apk add --update bash python3 uwsgi uwsgi-python openjdk11-jre-headless; python3 -m ensurepip
RUN echo "www-data:x:1001:1001:www-data:/var/www:/usr/sbin/nologin" >> /etc/passwd; echo "www-data:x:1001:" >> /etc/group
-RUN chown www-data:www-data . -R
RUN pip3 install Flask redis compressinja Celery
@@ -14,10 +13,11 @@ ADD [ "https://github.com/tgckpg/BotanJS/releases/download/compressors/closure.j
, "https://github.com/tgckpg/BotanJS/releases/download/compressors/yuicompressor.jar" \
, "/opt/utils/" ]
-RUN chmod 644 /opt/utils/*.jar
-
COPY . /app/
+RUN chmod 644 /opt/utils/*.jar; \
+ chown www-data:www-data . -R
+
USER www-data
EXPOSE 5000
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/Meta.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/Meta.js
index 62d1ffc..495ae3b 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/Meta.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/Meta.js
@@ -65,13 +65,7 @@
else
{
IDOMElement( stage ).setAttribute(new DataKey( "value", code ));
-
- temp = stage.firstChild;
- temp.removeChild(temp.firstChild);
- stage.firstChild.appendChild(Dand.textNode( code ));
-
temp = stage;
-
}
i = { _code: code, _stage: temp };
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/RespH.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/RespH.js
new file mode 100644
index 0000000..c912f01
--- /dev/null
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/Snippet/RespH.js
@@ -0,0 +1,99 @@
+(function ()
+{
+ var ns = __namespace( "Astro.Blog.AstroEdit.Visualizer.Snippet" );
+
+ /** @type {System.utils.IKey} */
+ var IKey = __import( "System.utils.IKey" );
+ /** @type {System.utils.DataKey} */
+ var DataKey = __import( "System.utils.DataKey" );
+ /** @type {Dandelion.IDOMElement} */
+ var IDOMElement = __import( "Dandelion.IDOMElement" );
+ /** @type {Dandelion} */
+ var Dand = __import( "Dandelion" );
+ /** @type {Components.MessageBox} */
+ var MessageBox = __import( "Components.MessageBox" );
+
+ var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
+ var unescapeStr = ns[ NS_INVOKE ]( "unescapeStr" );
+
+ var resph = function( insertSnippet, snippetWrap, createContext, override )
+ {
+ var temp, i, j
+
+ , handler = function ()
+ {
+ // Input fields
+ var v_snippetInput = Dand.wrap( "textarea", null, "v_snippet_input" );
+
+ if ( this._stage )
+ {
+ v_snippetInput.value = this._code;
+ }
+
+ // Popup MessageBox
+ new MessageBox(
+ "Insert Response Headers"
+ , v_snippetInput
+ , "OK", "Cancel"
+ , visualizer.bind({ code: v_snippetInput, stage: this._stage })
+ ).show();
+ }
+
+ , visualizer = function( submitted, override )
+ {
+ var code, stage = this.stage;
+
+ code = override ? unescapeStr( override.value ) : this.code.value;
+
+ if (submitted && code)
+ {
+ if (!stage)
+ {
+ // Visualize component
+ temp = Dand.wrap(
+ 'span', null, "flsf"
+ , "Response Headers"
+ , [
+ new DataKey( "value", code )
+ , new IKey(
+ "style", "background-color: #444; color: white; padding: 0.2em 0.5em;"
+ )
+ ]
+ );
+ insertSnippet(j = snippetWrap( "RespH", temp, false, "span" ), Boolean(override));
+ }
+ else
+ {
+ IDOMElement( stage ).setAttribute(new DataKey( "value", code ));
+ temp = stage;
+ }
+
+ i = { _code: code, _stage: temp };
+
+ // Set context menu
+ createContext( i, j, handler );
+ }
+ };
+
+ if ( override )
+ {
+ visualizer( true, override );
+ override = false;
+ }
+ else
+ {
+ return handler;
+ }
+
+ return true;
+ };
+
+ var compile = function (stage)
+ {
+ return "[resph]" + escapeStr( IDOMElement(stage).getDAttribute("value") ) + "[/resph]";
+ };
+
+ __static_method( resph, "compile", compile );
+
+ ns[ NS_EXPORT ]( EX_CLASS, "RespH", resph );
+})();
diff --git a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
index 77fbf7c..4c46fad 100644
--- a/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
+++ b/botanjs/src/Astro/Blog/AstroEdit/Visualizer/_this.js
@@ -38,6 +38,7 @@
, "SiteFile" , "background: royalblue;"
, "Heading" , ""
, "Footnote" , ""
+ , "RespH" , ""
, "Meta" , ""
, "ArticleLink" , ""
, "ArticleContent" , ""
diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml
index d98c869..fb10527 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.03
+ image: registry.k8s.astropenguin.net/astrojs:2022.04.05.05
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.03
+ image: registry.k8s.astropenguin.net/astrojs:2022.04.05.05
securityContext:
runAsGroup: 1001
runAsNonRoot: true