Update _Dashmini.mrc

This commit is contained in:
Sunblade 2025-09-13 10:52:01 +00:00
parent 8778341bfa
commit 876add9a13
1 changed files with 73 additions and 60 deletions

View File

@ -1,60 +1,73 @@
/* /*
Dashmini 0.1 Dashmini 0.1
By Sunblade By Sunblade
sunblade@tilde.club sunblade@tilde.club
https://tilde.club/~sunblade/ https://tilde.club/~sunblade/
Usage: Usage:
/dashmini "gemini://url" (without quotes) /dashmini "gemini://url" (without quotes)
*/ BSD-3-Clause License
Copyright (c) 2025 Sunblade.
alias -l gemurlformat {
if (($right($1,4) != .gmi) && ($right($1,1) != $chr(47))) { Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
return $+($1,/index.gmi)
} 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
else {
return $1 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
}
} 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
alias dashmini {
if (!$window(@dashmini)) { THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
window -k @dashmini
} */
var %f = $1
var %u = $gemurlformat($1) alias -l gemurlformat {
var %h = $token(%f,2,47) if (($right($1,4) != .gmi) && ($right($1,1) != $chr(47))) {
sockopen -e dashmini %h 1965 return $+($1,/index.gmi)
sockmark dashmini $1 }
} else {
on 1:sockopen:dashmini:{ return $1
if ($sockerr > 0) { echo -st * /dashmini : Unable to connect. | return } }
echo -tg @dashmini * /dashmini : Connection successful to $sock($sockname).mark $+([,$sock($sockname).ip,]) }
sockwrite -n $sockname $sock($sockname).mark alias dashmini {
echo -tg @dashmini * /dashmini : Receiving informations... if (!$window(@dashmini)) {
} window -k @dashmini
}
on 1:sockread:dashmini:{ var %f = $1
if ($sockerr > 0) { echo -tg @dashmini * /dashmini : An error has ocurred. Connection closed. | return } var %u = $gemurlformat($1)
var %read var %h = $token(%f,2,47)
;var %line = 1 sockopen -e dashmini %h 1965
:read sockmark dashmini $1
sockread -f %read }
if ($sockbr == 0) return on 1:sockopen:dashmini:{
echo -tg @dashmini * /dashmini : %read if ($sockerr > 0) { echo -st * /dashmini : Unable to connect. | return }
inc %line echo -tg @dashmini * /dashmini : Connection successful to $sock($sockname).mark $+([,$sock($sockname).ip,])
goto read sockwrite -n $sockname $sock($sockname).mark
} echo -tg @dashmini * /dashmini : Receiving informations...
}
on 1:sockclose:dashmini:{
echo -tg @dashmini * /dashmini : The connection has been closed. on 1:sockread:dashmini:{
} if ($sockerr > 0) { echo -tg @dashmini * /dashmini : An error has ocurred. Connection closed. | return }
var %read
on *:hotlink:*:@dashmini:{ ;var %line = 1
if ($hotlink(event) == sclick) { :read
if ($hotlink(match) isurl) { sockread -f %read
dashmini $gemurlformat($hotlink(match)) if ($sockbr == 0) return
} echo -tg @dashmini * /dashmini : %read
} inc %line
} goto read
}
on 1:sockclose:dashmini:{
echo -tg @dashmini * /dashmini : The connection has been closed.
}
on *:hotlink:*:@dashmini:{
if ($hotlink(event) == sclick) {
if ($hotlink(match) isurl) {
dashmini $gemurlformat($hotlink(match))
}
}
}