changeset 960:0d9caeab3d81 draft

Instant notify by "@all" sign at the beginning of article.
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 29 Jan 2022 10:41:41 +0900
parents 193d9d2ed9c9
children 3444e0a72bb7
files examples/common/default/default.css s4-blog.sh s4-main.js
diffstat 3 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Fri Dec 24 08:39:25 2021 +0900
+++ b/examples/common/default/default.css	Sat Jan 29 10:41:41 2022 +0900
@@ -152,6 +152,10 @@
 td.repl h2:before {content: "■"; color: #a22;}
 td.repl h3:before {content: "◆"; color: #a22;}
 td.repl h4:before {content: "○";}
+td.repl div.atall {
+    color: white; background: #66f; padding: 0 0.8ex;
+    display: inline-block; border-radius: 0.8ex;
+}
 .blog_replies td.repatt {min-width: 12em;}
 table.blog_replies iframe {
     width: 80%; min-height: 300px; max-width: 50em; max-height: 80vw;
--- a/s4-blog.sh	Fri Dec 24 08:39:25 2021 +0900
+++ b/s4-blog.sh	Sat Jan 29 10:41:41 2022 +0900
@@ -43,7 +43,10 @@
   blogtitle=`getvalbyid blog title "$blogid"`
   blogurl="$urlbase?replyblog+$blogid"
   action=${4:-書き込み}
-  mode=`getvalbyid blog notify "$blogid"`
+  case "$3" in
+    @all*)	mode=all ;;
+    *)		mode=`getvalbyid blog notify "$blogid"` ;;
+  esac
   isgroup "$blogowner" && _isgroup=true || _isgroup=false
   ### EXCEPT=`sqlquote "$user"`	## User should receive to feal some annoyance
   case $mode in
@@ -94,6 +97,8 @@
       fi
     elif echo "$firstline" | grep -q "^## "; then
       subject=${firstline#\#\# }
+    elif echo "$firstline" | grep -q "^@all "; then
+      subject=${firstline#@all }
     fi
   else
     # This else block is not symmetry, check later(2020-1209)
@@ -609,7 +614,9 @@
   ntmode="通知モード=$blog_notify${blog_team:+ (team=$blog_team)}
 記事の1行目を「## 」(半角シャープシャープ空白=大見出し)
 にするとそれより後ろの部分がSubject(件名)になります。
-If the first line begins with &quot;## &quot;, sent it as Subject of email."
+記事先頭に @all で全員(チーム所有の場合はチーム全体)通知になります。
+If the first line begins with &quot;## &quot;, sent it as Subject of email.
+If begins with &quot;@all&quot;, notify to all group(or team) members."
   textform=$(cat<<-EOF
 <div class="fold">
 <input type="checkbox" id="cmt" checked><label
--- a/s4-main.js	Fri Dec 24 08:39:25 2021 +0900
+++ b/s4-main.js	Sat Jan 29 10:41:41 2022 +0900
@@ -713,6 +713,15 @@
 	pjaxHistoryPush(preview);
 	btn.focus();
     }
+    function helpMarkdownAt(e) {
+	var area = e.target, pos = area.selectionStart;
+	if (pos == 0) {
+	    area.value = "@all" + area.value;
+	    area.selectionStart = area.selectionEnd = 4;
+	    dispInfoMomentary("@all で全員に通知します", area.parentNode);
+	    e.preventDefault();
+	}
+    }
     function helpMarkdown(e) {
 	switch (e.key) {
 	case "Backspace": helpMarkdownBS(e); break;
@@ -721,6 +730,7 @@
 	case "p":  if (e.metaKey) helpMarkdownPreview(e.target); break;
 	case "{":  helpMarkdownBrace(e); break;
 	case "}":  helpMarkdownBraceClose(e); break;
+	case "@":  helpMarkdownAt(e); break;
 	}
     }
     /* Init event listeners */
@@ -810,6 +820,14 @@
 	}
 	// Hack article_m links
 	registPjaxViewers(document.querySelectorAll("a[href]"));
+	// Enclose "@all" with span
+	for (i of document.querySelectorAll("td.repl")) {
+	    let ii = i.innerHTML;
+	    if (ii.startsWith("@all")) {
+		ii = ii.replace(/^@all/,'<div class="atall">@all</div>');
+		i.innerHTML = ii;
+	    }
+	}
     }
     function initGrpAction() {
 	var rev = document.getElementById("reverse");

yatex.org