From f7b4edde2361da0c1307fb27c0b32d89b7c79e78 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 20 May 2024 20:52:40 +0800 Subject: [PATCH] add some --- base/web/serve.go | 3 +++ core/chat/flows.css | 24 +++++++++++-------- core/chat/flows.go | 1 + core/chat/flows.js | 57 ++++++++++++++++++++++++++------------------- misc/git/search.js | 2 +- 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/base/web/serve.go b/base/web/serve.go index 4e5e14a5..6ff81c6c 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -90,6 +90,9 @@ func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) boo if strings.HasPrefix(r.URL.Path, "/v/") { return Render(msg, ice.RENDER_DOWNLOAD, path.Join(ice.USR_VOLCANOS, strings.TrimPrefix(r.URL.Path, nfs.V))) } else if kit.HasPrefix(r.URL.Path, "/p/") { + if kit.Contains(r.URL.String(), "render=replace") { + return false + } p := strings.TrimPrefix(r.URL.Path, "/p/") return (!ispod && kit.HasPrefix(p, nfs.SRC) || kit.HasPrefix(p, ice.USR_ICEBERGS, ice.USR_ICONS)) && nfs.Exists(msg, p) && Render(msg, ice.RENDER_DOWNLOAD, p) } else if kit.HasPrefix(r.URL.Path, "/m/") { diff --git a/core/chat/flows.css b/core/chat/flows.css index a9701963..ef4b795b 100644 --- a/core/chat/flows.css +++ b/core/chat/flows.css @@ -1,11 +1,15 @@ body { --web-flows-done:lightgreen; --web-flows-fail:var(--danger-bg-color); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg line.fail { stroke:var(--web-flows-fail); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg line.done { stroke:var(--web-flows-done); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg line.select { stroke:var(--notice-bg-color); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg rect.fail { stroke:var(--web-flows-fail); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg rect.done { stroke:var(--web-flows-done); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg rect.select { stroke:var(--notice-bg-color); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg text { dominant-baseline:middle; } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg text.fail { stroke:var(--web-flows-fail); fill:var(--web-flows-fail); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg text.done { stroke:var(--web-flows-done); fill:var(--web-flows-done); } -fieldset.web.flows>div.output>div.layout>div.layout>div.content svg text.select { stroke:var(--notice-bg-color); fill:var(--notice-bg-color); } +$content svg line.fail { stroke:var(--web-flows-fail); } +$content svg line.done { stroke:var(--web-flows-done); } +$content svg line.select { stroke:var(--notice-bg-color); } +$content svg rect.fail { stroke:var(--web-flows-fail); } +$content svg rect.done { stroke:var(--web-flows-done); } +$content svg rect.select { stroke:var(--notice-bg-color); } +$content svg text { dominant-baseline:middle; } +$content svg text.fail { stroke:var(--web-flows-fail); fill:var(--web-flows-fail); } +$content svg text.done { stroke:var(--web-flows-done); fill:var(--web-flows-done); } +$content svg text.select { stroke:var(--notice-bg-color); fill:var(--notice-bg-color); } +$content fieldset.can._action { position:absolute; bottom:var(--action-height); } +$content fieldset.can._action>legend { display:none; } +$content fieldset.can._action>div.status { display:none; } +$content fieldset.can._action>div.action { display:contents; } diff --git a/core/chat/flows.go b/core/chat/flows.go index 6a0e2933..a4c90fda 100644 --- a/core/chat/flows.go +++ b/core/chat/flows.go @@ -29,6 +29,7 @@ func init() { m.PushAction(mdb.PLUGIN, mdb.DELETE) } m.Display("") + m.DisplayCSS("") }}, }) } diff --git a/core/chat/flows.js b/core/chat/flows.js index 98d9f56e..522ee8a0 100644 --- a/core/chat/flows.js +++ b/core/chat/flows.js @@ -26,10 +26,16 @@ Volcanos(chat.ONIMPORT, { // can.onappend._status(can, can.base.Obj(msg.Option(ice.MSG_STATUS))) can.onappend.plugin(can, {index: web.WIKI_DRAW, style: html.OUTPUT, display: "/plugin/local/wiki/draw.js", height: can.ui.content.offsetHeight, width: can.ui.content.offsetWidth}, function(sub) { sub.run = function(event, cmds, cb) { cb(can.request(event)) } - sub.onexport.output = function(_sub, _msg) { - sub.Action(svg.GO, "manual"), sub.Action(ice.MODE, html.RESIZE), can.onmotion.hidden(can, sub._action) - value._content_plugin = sub, can.onimport.layout(can), can.onimport._flows(can, _sub, value) - } + sub.onexport.output = function(_sub, _msg) { value._content_plugin = sub, can.onimport._toolkit(can, value) } + }, can.ui.content||can._output) + }, + _toolkit: function(can, value) { + can.onappend.plugin(can, {index: "can._action", width: can.ui.content.offsetWidth/2}, function(sub) { + sub.Conf("space", can.ConfSpace()), sub.Conf("index", can.ConfIndex()+":"+value.zone) + sub.run = function(event, cmds, cb) { cb(can.request(event)) } + sub.onexport.output = function(_sub) { + _sub.onaction._select = function(event, _sub) { can.onimport._flows(can, value) } + sub.onappend._action(_sub, can.onaction._toolkit), value._toolkit_plugin = sub, can.onimport._flows(can, value) } }, can.ui.content||can._output) }, _profile: function(can, item) { can.onexport.hash(can, can.db.value.zone, item.hash) @@ -41,10 +47,13 @@ Volcanos(chat.ONIMPORT, { sub.onaction._close = function() { can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } }, can.ui.profile) }, - _flows: async function(can, sub, value) { - var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) - var matrix = {}, horizon = can.Action("direct") == "horizon"; can.onmotion.clear(can, sub.ui.svg) - async function sleep() { return new Promise(resolve => { setTimeout(resolve, can.Action("delay")) }) } + _flows: async function(can, value) { + can.onimport.layout(can) + var sub = value._content_plugin.sub + var _sub = value._toolkit_plugin.sub + var margin = can.onexport.margin(_sub), height = can.onexport.height(_sub), width = can.onexport.width(_sub) + var matrix = {}, horizon = value._toolkit_plugin.Action("direct") == "horizon"; can.onmotion.clear(can, sub.ui.svg) + async function sleep() { return new Promise(resolve => { setTimeout(resolve, _sub.Action("delay")) }) } async function show(item, main) { var prev = "from", from = "prev"; if (horizon) { var prev = "prev", from = "from" } while (matrix[can.core.Keys(item.x, item.y)]) { if (horizon && main || !horizon && !main) { item.y++ @@ -62,7 +71,7 @@ Volcanos(chat.ONIMPORT, { if (item.from || item.prev) { item._line = sub.onimport.draw(sub, {shape: svg.LINE, points: horizon && item.from || !horizon && !item.from? [{x: item.x*width+width/2, y: item.y*height-margin}, {x: item.x*width+width/2, y: item.y*height+margin}]: [{x: item.x*width-margin, y: item.y*height+height/2}, {x: item.x*width+margin, y: item.y*height+height/2}] - }) } can.onimport._block(can, sub, item, item.x*width, item.y*height), await sleep() + }) } can.onimport._block(can, value, item, item.x*width, item.y*height), await sleep() var next = 0, to = 1; if (horizon) { var next = 1, to = 0 } if (main) { var _item = item.to; if (_item) { _item.x = item.x+to, _item.y = item.y+next, await show(_item) } @@ -73,26 +82,33 @@ Volcanos(chat.ONIMPORT, { } } value._root.x = 0, value._root.y = 0, await show(value._root, true) }, - _block: function(can, sub, item, x, y) { - var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) + _block: function(can, value, item, x, y) { + var sub = value._content_plugin.sub + var _sub = value._toolkit_plugin.sub + var margin = can.onexport.margin(_sub), height = can.onexport.height(_sub), width = can.onexport.width(_sub) var rect = sub.onimport.draw(sub, {shape: svg.RECT, points: [{x: x+margin, y: y+margin}, {x: x+width-margin, y: y+height-margin}]}) var text = sub.onimport.draw(sub, {shape: svg.TEXT, points: [{x: x+width/2, y: y+height/2}], style: {inner: item.name||item.index.split(nfs.PT).pop()}}) item._rect = rect, item._text = text, can.core.ItemCB(can.ondetail, function(key, cb) { text[key] = rect[key] = function(event) { cb(event, can, sub, item) } }) if (item.status) { item._line && item._line.Value(html.CLASS, item.status), rect.Value(html.CLASS, item.status), text.Value(html.CLASS, item.status) } if (can.db.value.zone == can.db.hash[0] && item.hash == can.db.hash[1] && can.onexport.session(can, "profile.show") != ice.FALSE) { can.onmotion.delay(can, function() { can.onimport._profile(can, item) }) } }, -}, [""]) + layout: function(can) { + can.ui.layout(can.ConfHeight(), can.ConfWidth(), 0, function(height, width) { + var sub = can.db.value && can.db.value._toolkit_plugin + if (sub) { sub.onimport.size(sub, html.ACTION_HEIGHT, width/2, false), can.page.style(can, sub._target, html.LEFT, width/4) } + }) + }, +}) Volcanos(chat.ONACTION, { - /* - list: ["create", "play", "prev", "next", + _toolkit: [ + "prev", "next", ["travel", "deep", "wide"], ["direct", "vertical", "horizon"], [html.MARGIN, 10, 20, 40, 60], - [html.HEIGHT, 80, 100, 120, 140, 200], + [html.HEIGHT, 60, 80, 100, 120, 140, 200], [html.WIDTH, 200, 240, 280, 400], - ["delay", 100, 200, 500, 1000], + ["delay", 30, 100, 200, 500, 1000], ], _trans: {play: "播放", prev: "上一步", next: "下一步"}, - */ travel: function() {}, delay: function() {}, play: function(event, can) { var list = can.onexport.travel(can, can.db.value._root, true) can.core.List(list, function(item) { item._line && item._line.Value(html.CLASS, ""), item._rect.Value(html.CLASS, ""), item._text.Value(html.CLASS, "") }) @@ -111,13 +127,6 @@ Volcanos(chat.ONACTION, { can.core.List(list, function(item, index) { if (item == can.db.current) { next = list[index+1] } }), can.db.current = next } can.ondetail._select(event, can, can.db.current) }, - show: function(event, can) { can.onmotion.toggle(can, can.ui.profile), can.onimport.layout(can) }, - exec: function(event, can) { can.onmotion.toggle(can, can.ui.display), can.onimport.layout(can) }, - clear: function(event, can) { if (can.onmotion.clearFloat(can)) { return } - if (can.page.isDisplay(can.ui.profile)) { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } - if (can.page.isDisplay(can.ui.display)) { return can.onmotion.hidden(can, can.ui.display), can.onimport.layout(can) } - can.onmotion.toggle(can, can.ui.project), can.onimport.layout(can) - }, plugin: function(event, can, msg) { can.ondetail._select(event, can, can.db.list[msg.Option(mdb.HASH)]) }, }) Volcanos(chat.ONDETAIL, { diff --git a/misc/git/search.js b/misc/git/search.js index 62fac75c..a3d1dcc3 100644 --- a/misc/git/search.js +++ b/misc/git/search.js @@ -16,7 +16,7 @@ Volcanos(chat.ONIMPORT, { ]}]}, {view: [wiki.CONTENT, html.DIV, value.description]}, {view: html.ACTION, inner: value.action, _init: function(target) { can.onappend.mores(can, target, value, 5) }}, ]} - })), can.onappend.board(can, msg), can.onimport.layout(can), can.user.isWindows && can.onappend.scroll(can, can._output) + })), can.onappend.board(can, msg), can.onimport.layout(can), can.user.isWindows && can.onappend.scroll(can) }, layout: function(can) { can.onlayout.expand(can, can._output, can.user.isMobile && !can.user.isLandscape()? can.ConfWidth(): 320) }, }, [""])