Various bug fix due to CSP headers

SiteLibrary added name display on album view
Optimizations & removed some obsolete files
This commit is contained in:
2022-04-09 20:45:48 +08:00
parent 3b4ba29b6e
commit b0ecbe42c3
27 changed files with 214 additions and 665 deletions

View File

@@ -0,0 +1,5 @@
.v_boundary[data-type="AcquireLib"] > span {
background-color: #444;
color: white;
padding: 0.2em 0.5em;
}

View File

@@ -54,12 +54,7 @@
temp = Dand.wrap(
'span', null, "flsf"
, "AcquireLib: " + src
, [
new DataKey( "value", src )
, new IKey(
"style", "background-color: #444; color: white; padding: 0.2em 0.5em;"
)
]
, [ new DataKey( "value", src ) ]
);
insertSnippet(j = snippetWrap("AcquireLib", temp, false, 'span'), Boolean(override));
}

View File

@@ -0,0 +1,5 @@
.v_boundary[data-type="Meta"] > span {
background-color: #444;
color: white;
padding: 0.2em 0.5em;
}

View File

@@ -53,12 +53,7 @@
temp = Dand.wrap(
'span', null, "flsf"
, "Meta Tags"
, [
new DataKey( "value", code )
, new IKey(
"style", "background-color: #444; color: white; padding: 0.2em 0.5em;"
)
]
, [ new DataKey( "value", code ) ]
);
insertSnippet(j = snippetWrap( "Meta", temp, false, "span" ), Boolean(override));
}

View File

@@ -0,0 +1,5 @@
.v_boundary[data-type="RespH"] > span {
background-color: #444;
color: white;
padding: 0.2em 0.5em;
}

View File

@@ -0,0 +1,18 @@
.v_boundary[data-type="Video"] {
width: 640px; height: 390px;
background-color: black;
padding: 0;
}
.v_boundary[data-type="Video"] .v_box {
width: 640px; height: 390px;
position: relative;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.v_boundary[data-type="Video"] .v_description {
text-align: left;
padding-left: 0.5em;
}

View File

@@ -14,43 +14,46 @@
var MessageBox = __import( "Components.MessageBox" );
var getData = __import( "System.Net.getData" );
var BLANK_IMG = __import( "Dandelion.StaticRes.BLANK_IMG" );
var video = function (insertSnippet, snippetWrap, createContext, override)
{
var temp, i, j
, getVimeoThumbnail = function (vtag)
var temp, i, j, imgSrc
, getVimeoThumbnail = function( v )
{
getData("//vimeo.com/api/oembed.json?url=https%3A//vimeo.com/" + vtag.getAttribute("data-value"), setThumbnail.bind(vtag), noThumb.bind(vtag));
getData(
"//vimeo.com/api/oembed.json?url=https%3A//vimeo.com/" + v
, setThumbnail
, noThumb
);
}
, noThumb = function ()
, setImgSrc = function( url )
{
if( imgSrc ) imgSrc.src = url;
}
, noThumb = function () { }
, setThumbnail = function (str)
{
this.style.background = "black url(" + JSON.parse(str)["thumbnail_url"] + ") center center no-repeat";
setImgSrc( JSON.parse(str)["thumbnail_url"] );
}
, handler = function ()
{
// Input fields
var input_url = Dand.wrap('input', null, "v_snippet_input_single", null, new IKey("type", "text"));
// Popup MessageBox
new MessageBox("Insert video snippet"
, Dand.wrape([ Dand.wrapc("v_instruction flsf", "Paste a vimeo/Youtube link below:"), input_url ])
, "OK", "Cancel", visualizer.bind(input_url)
).show();
}
, visualizer = function (submitted, override)
{
var t, v;
if (override)
{
v = override.value;
@@ -83,35 +86,34 @@
}
}
}
if (submitted)
{
// Visualize component
temp = Dand.wrapc('v_box', Dand.wrapc('v_description', "Video(url): " + t)
, [
new DataKey("value", v)
, new DataKey("type", i)
, new IKey("style"
, "width: 640px; height: 390px;"
+ ( (i[0] == "v") ? "" : ("background: black url(//img.youtube.com/vi/" + v + "/hqdefault.jpg) no-repeat center center;") )
)
]
temp = Dand.wrapc('v_box'
, [
Dand.wrapc( 'v_description', i[0].toUpperCase() + i.substr(1) + ": " + v )
, imgSrc = Dand.wrapna( "img", [ new IKey( "src", BLANK_IMG ) ] )
]
, [ new DataKey("value", v), new DataKey("type", i) ]
);
if (i[0] == "v")
if( i[0] == "v" )
{
getVimeoThumbnail(temp);
getVimeoThumbnail( v );
}
else
{
setImgSrc( "//img.youtube.com/vi/" + v + "/hqdefault.jpg" );
}
insertSnippet(j = snippetWrap("Video", temp), Boolean(override));
// Set context menu
createContext(null, j);
}
}
;
if (override)
{
visualizer(true, override);
@@ -123,13 +125,13 @@
}
return true;
};
var compile = function (stage)
{
// [video type=\"youtube\"]" + v[2] + "[/video]
var element = IDOMElement(stage)
, type = element.getDAttribute("type");
return "[video type=\"" + type + "\"]" + element.getDAttribute("value") + "[/video]";
};

View File

@@ -104,3 +104,19 @@ div[data-type="token"]:after {
div[data-type="token"]:hover:after {
color: rgba( 255, 255, 255, 0.5 );
}
#ae_visual_snippets > span[data-name="code"] { background: white; color: cornflowerblue; }
#ae_visual_snippets > span[data-name="image"] { background: #ff0084; }
#ae_visual_snippets > span[data-name="sound"] { background: YellowGreen; }
#ae_visual_snippets > span[data-name="video"] { background: Crimson; }
#ae_visual_snippets > span[data-name="spoiler"] { background: cornflowerblue; }
#ae_visual_snippets > span[data-name="link"] { background: blue; }
#ae_visual_snippets > span[data-name="acquirelib"] { background: black; }
#ae_visual_snippets > span[data-name="html"] { background: coral; }
#ae_visual_snippets > span[data-name="sitefile"] { background: royalblue; }
#ae_visual_snippets > span[data-name="heading"] { }
#ae_visual_snippets > span[data-name="footnote"] { }
#ae_visual_snippets > span[data-name="resph"] { }
#ae_visual_snippets > span[data-name="meta"] { }
#ae_visual_snippets > span[data-name="articlelink"] { }
#ae_visual_snippets > span[data-name="articlecontent"] { }

View File

@@ -26,23 +26,23 @@
/** @type {Astro.Blog.Config} */
var Config = __import( "Astro.Blog.Config" );
var snippetList = IKey.quickDef(
"Code" , "background: white; color: cornflowerblue;"
, "Image" , "background: #ff0084;"
, "Sound" , "background: YellowGreen;"
, "Video" , "background: Crimson;"
, "Spoiler" , "background: cornflowerblue;"
, "Link" , "background: blue;"
, "AcquireLib" , "background: black;"
, "Html" , "background: coral;"
, "SiteFile" , "background: royalblue;"
, "Heading" , ""
, "Footnote" , ""
, "RespH" , ""
, "Meta" , ""
, "ArticleLink" , ""
, "ArticleContent" , ""
);
var snippetList = [
"Code"
, "Image"
, "Sound"
, "Video"
, "Spoiler"
, "Link"
, "AcquireLib"
, "Html"
, "SiteFile"
, "Heading"
, "Footnote"
, "RespH"
, "Meta"
, "ArticleLink"
, "ArticleContent"
];
var snippetNs = "Astro.Blog.AstroEdit.Visualizer.Snippet.";
//// Document Visualizer visualize snippets, used in AstroEdit and comments
@@ -388,19 +388,7 @@
}
// Append module"s control
temp = Dand.wrapne(
"span"
, mod_name
, new IKey(
"style"
, utils.objSearch(
snippetList
/** @param {System.utils.IKey} a */
, function( a ) { return a.keyName.toLowerCase() == mod_name }
, "keyValue"
)
)
);
temp = Dand.wrapne( "span", mod_name, new IKey( "data-name", mod_name ) );
snippetControls.appendChild( temp );
snippetControls.appendChild( Dand.textNode( "\t" ) );
@@ -502,9 +490,9 @@
article.invoke(this);
var modules = [];
for( var i in snippetList )
for( var i = 0; i < snippetList.length; i ++ )
{
modules[ modules.length ] = snippetNs + snippetList[i].keyName;
modules[ modules.length ] = snippetNs + snippetList[i];
}
var ldr = new Loader( service_uri, "o" );