Mercurial > hgrepos > hgweb.cgi > s4
changeset 791:567980314463 feature-world
World and Migration structures refined
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sat, 13 Jun 2020 17:31:27 +0900 |
parents | 7ac852e8c216 |
children | e086e07dfc9c |
files | examples/common/default/default.css examples/common/default/html.m4.html s4-funcs.sh s4-migrate.sh s4-newworld.sh s4-world.sh |
diffstat | 6 files changed, 81 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/common/default/default.css Sat Jun 13 17:04:29 2020 +0900 +++ b/examples/common/default/default.css Sat Jun 13 17:31:27 2020 +0900 @@ -16,6 +16,7 @@ box-shadow: #242 2px 3px 5px; text-shadow: #fff 0px 0px 10px; } +div.topmenu ul li.worldname {background: #eeeeff;} div.topmenu ul li:hover {background: #8fa;} div.topmenu ul a {text-decoration: none;}
--- a/examples/common/default/html.m4.html Sat Jun 13 17:04:29 2020 +0900 +++ b/examples/common/default/html.m4.html Sat Jun 13 17:31:27 2020 +0900 @@ -25,10 +25,12 @@ Members">参加者一覧</a></li> <li><a href="?grps" accesskey="3" title="Shortcut: 3 Groups">グループ一覧</a></li> -ifdef(`_S4WORLD_',`',` <li><a href="?invite" accesskey="4" title="Shortcut: 4 +ifdef(`_S4WORLDNAME_',`', +` <li><a href="?invite" accesskey="4" title="Shortcut: 4 Invite">招待</a></li>')dnl <li><a href="?login" accesskey="5" title="Shortcut: 5 Sign out">再ログイン</a></li> <!-- <li><a href="?userconf">userconf</a></li> --> +ifdef(`_S4WORLDNAME_',`<li class="worldname">@_S4WORLDNAME_</li>',`')dnl </ul> </div>
--- a/s4-funcs.sh Sat Jun 13 17:04:29 2020 +0900 +++ b/s4-funcs.sh Sat Jun 13 17:31:27 2020 +0900 @@ -94,47 +94,16 @@ esac # If S4MASTERDB is set, behave in another world -if [ -n "$S4MASTERDB" -a -s "$S4MASTERDB" ]; then +### if [ -n "$S4MASTERDB" -a -s "$S4MASTERDB" ]; then +# If S4WORLDLIST is set, this s4 have world! +if [ -n "$S4WORLDLIST" ]; then . ./s4-world.sh 2>> tmp/debug.out + # Variables set in s4-world.sh + # $S4WORLDS, $S4WROLDNAME + # Files created in s4-world.sh + # $worldlistfile, $worldoptionfile, $worldnamefile + err S4WORLDS set to $S4WORLDS ----- fi -case "$S4WORLDLIST" in - *:*:*) - worldlistfile=cache/worldlist - worldoptionfile=cache/worldoption - if [ ! -e $worldlistfile -o $worldlistfile -ot s4-config.sh \ - -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh \ - -o s4-funcs.sh -nt $worldoptionfile ] - then - echo S4MASTERURL=$S4MASTERURL >> tmp/debug.out - cat <<-EOF > $worldlistfile - ${touchpanel:+ : ▼}<div><table> - <tr><th>World List</th></tr> - <tr><td>⇒ <a href="$S4MASTERURL">Base</a></td></tr> - EOF - true > $worldoptionfile - for i in $S4WORLDLIST; do - echo $i | { - IFS=: read name short d - cgi="s4-world-$short$cgiext" - conf="s4-config-$short.sh" - cat<<-EOF >>$worldlistfile - <tr><td title="$d">⇒ <a href="$cgi">$name</a></td></tr> - EOF - cat<<-EOF >>$worldoptionfile - <option title="$d" value="$conf">$name</option> - EOF - } - done - if [ -s "$worldoptionfile" ]; then - echo "<option value=\"s4-config.sh\">Base</option>" >> $worldoptionfile - echo "</table>$nl</div>" >> $worldlistfile - else - true > $worldoptionfile; true > $worldlistfile # Remove contents - fi - fi - [ -s "$worldlistfile" ] && S4WORLDS=": spaste(\`$worldlistfile')" - ;; -esac [ -f ./s4-cgi.sh ] && . ./s4-cgi.sh @@ -492,7 +461,7 @@ _m4() { #S4NAME=f,f,f m4 ${S4NAME:+"-D_S4NAME_=${S4NAME}"} ${S4CSS:+-D_S4CSS_="$S4CSS"} \ - ${S4WORLD:+-D_S4WORLD_="$S4WORLD"} \ + ${S4WORLDNAME:+-D_S4WORLDNAME_="$S4WORLDNAME"} \ ${S4WORLDS:+-D_S4WORLDS_="$S4WORLDS"} "$@" } ismember() { @@ -2235,7 +2204,8 @@ tf=$tmpd/title.$$ pf=$tmpd/profile.$$ bf=$tmpd/blogs.$$ sf=$tmpd/search.$$ search_form "$search_form_args" > $sf - printf "%s さん%s" "$gecos" "${S4WORLD:+@$S4WORLD}" |htmlescape > $tf + printf "%s さん%s" "$gecos" "${S4WORLDNAME:+@$S4WORLDNAME}" \ + | htmlescape > $tf { echo "<div class=\"noprofimg\">" viewtable $formdir/user.def user $1 echo "</div>" @@ -2534,7 +2504,7 @@ # Note that mtime is stored only in grp_s. ## err LE:sql.1="$sql" total=`query "with x as ($sql) select count(*) from x;"` - echo "${entity} 一覧" "${S4WORLD:+@$S4WORLD}" | html h2 + echo "${entity} 一覧" "${S4WORLDNAME:+@$S4WORLDNAME}" | html h2 echo '<div class="listentry">' # List-entry div # Show owner/member filter button METHOD=GET @@ -3802,20 +3772,19 @@ # This shoud be done by foreign_key rules, but some db lack them query<<-EOF -- Find blogs that have no parent - CREATE TEMPORARY VIEW IF NOT EXISTS orphanedblog AS - SELECT blog.id,val FROM blog JOIN blog_s bs - ON blog.id=bs.id AND key='owner' - WHERE val NOT IN (SELECT gname FROM grp) - AND val NOT IN (SELECT name FROM user); - -- Remove them + WITH orphanedblog AS ( + SELECT blog.id,val FROM blog JOIN blog_s bs + ON blog.id=bs.id AND key='owner' + WHERE val NOT IN (SELECT gname FROM grp) + AND val NOT IN (SELECT name FROM user); + ) -- Remove them DELETE FROM blog WHERE id IN (SELECT id FROM orphanedblog); -- Find articles that have no parent blog - CREATE TEMPORARY VIEW IF NOT EXISTS orphanedarticle AS - SELECT id FROM article - WHERE blogid NOT IN (SELECT id FROM blog); - - -- Remove them + WITH orphanedarticle AS ( + SELECT id FROM article + WHERE blogid NOT IN (SELECT id FROM blog); + ) -- Remove them DELETE FROM article WHERE id IN (SELECT id FROM orphanedarticle); EOF }
--- a/s4-migrate.sh Sat Jun 13 17:04:29 2020 +0900 +++ b/s4-migrate.sh Sat Jun 13 17:31:27 2020 +0900 @@ -173,6 +173,7 @@ DELETE FROM main.grp WHERE rowid=$grid; EOF query "END;" + clean-orphaned echo "Done." else failure=-1
--- a/s4-newworld.sh Sat Jun 13 17:04:29 2020 +0900 +++ b/s4-newworld.sh Sat Jun 13 17:31:27 2020 +0900 @@ -8,6 +8,7 @@ . `dirname $0`/s4-config.sh if ! type htmlescape >/dev/null 2>&1; then . `dirname $0`/s4-funcs.sh ### > /dev/null 2>&1 + trap 'exit 1' INT QUIT fi dispname=$1 shortname=$2 @@ -80,5 +81,6 @@ wq EOF DB=db/$shortname.sq3 `dirname $0`/s4-init.sh +(S4MASTERDB=$db; db=db/$shortname.sq3; . ./s4-world.sh) (cd `dirname $0`; ln -s s4$cgiext s4-world-$shortname$cgiext) echo $newworld added
--- a/s4-world.sh Sat Jun 13 17:04:29 2020 +0900 +++ b/s4-world.sh Sat Jun 13 17:31:27 2020 +0900 @@ -1,8 +1,59 @@ #!/bin/sh +# Setup variables for running time +if $isCGI; then + case "$S4WORLDLIST" in + *:*:*) + worldlistfile=cache/worldlist + worldoptionfile=cache/worldoption + worldnamefile=cache/worldname + if [ ! -e $worldlistfile -o $worldlistfile -ot s4-config.sh \ + -o ! -e $worldoptionfile -o $worldoptionfile -ot s4-config.sh \ + -o s4-funcs.sh -nt $worldoptionfile ] + then + echo S4MASTERURL=$S4MASTERURL >> tmp/debug.out + cat <<-EOF > $worldlistfile + ${touchpanel:+ : }<div><table> + <tr><th>World List</th></tr> + <tr><td>⇒ <a href="${S4MASTERURL:-$URL}">Base</a></td></tr> + EOF + true > $worldoptionfile + for i in $S4WORLDLIST; do + echo $i | { + IFS=: read name short d + cgi="s4-world-$short$cgiext" + conf="s4-config-$short.sh" + cat<<-EOF >>$worldlistfile + <tr><td title="$d">⇒ <a href="$cgi">$name</a></td></tr> + EOF + cat<<-EOF >>$worldoptionfile + <option title="$d" value="$conf">$name</option> + EOF + echo "$name" > $worldnamefile.$short + } + done + if [ -s "$worldoptionfile" ]; then + echo "<option value=\"s4-config.sh\">Base</option>" >> $worldoptionfile + echo "</table>$nl</div>" >> $worldlistfile + else + true > $worldoptionfile; true > $worldlistfile # Remove contents + rm -f ${worldnamefile}.* + fi + fi + if [ -s "$worldlistfile" ]; then + S4WORLDS=": spaste(\`$worldlistfile')" + S4WORLDNAME=${S4WORLD:+`cat $worldnamefile.$S4WORLD`} + fi + ;; + esac +fi + +err "db=$db mas=$S4MASTERDB sessdb=$sessdb" +# If in parent world, no need to do rest of jobs if [ -z "$S4MASTERDB" -o ! -s "$S4MASTERDB" ]; then return fi +# Confim child if [ "$db" -ef "$S4MASTERDB" ]; then return # Points to the same file fi @@ -26,7 +77,6 @@ ## sqlite3 -cmd '.timer 1' -cmd '.echo 1' $db <<EOF err "Starting account synchronization" -err "db=$db mas=$S4MASTERDB sessdb=$sessdb" # num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF cat > tmp/sql <<EOF ATTACH DATABASE "$S4MASTERDB" AS m; @@ -70,4 +120,5 @@ if [ $num -eq 0 ]; then touch $syncflag fi +err "Account synchronization done in difference $num" return $num