Skip to content

Commit

Permalink
Release "3.2.3": Fix crash from issue #18
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 930e210f5d990ed4953cf49cb9d7528247c0d55d19b9158d60cec49f46649986
  • Loading branch information
pmacdona committed Oct 13, 2020
1 parent b653c5d commit fa0ff92
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ JSICURVER=$(shell fgrep 'define JSI_VERSION_M' src/jsi.h | cut -b29- | xargs | s

jsidone:
@echo ""
@echo "MAKE IS DONE!!!"
@echo "To build from Configs/ try 'make clean all CONF=X' where X is one of:"
@echo "MAKE COMPLETE!!!"
@echo "To build from Configs/ try 'make remake CONF=X' where X is one of:"
@echo " $(JSICONFS)."

jsiminreq:
Expand Down
27 changes: 16 additions & 11 deletions lib/Websrv.jsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function Websrv(args:string|array, conf:object=void)
closeTimeout:0, // Time til exit after close of final client websocket (ms).
confFile :'', // JSON file of options (eg. for useridPass or wsOpts).
docs :'', // Display markdown docs from this directory.
hist :false, // Let Vue employ history mode, short for urlFallback=url: useful for -docs/-app.
ignoreExit :false, // Ignore exit request.
initArg :[], // List of app modules to run.
isFile :false, // Url is a file, so throw if not exists.
Expand All @@ -34,21 +35,22 @@ function Websrv(args:string|array, conf:object=void)
onRecv :null, // Callback command to handle websocket msgs.
pageStr :'', // String to serve out as url.
port :0, // Start search for port.
portMax :1000, // Max times to increment-retry port if busy.
portMax :999, // Max times to increment-retry port if busy.
query :'', // Query to append to url.
rootdir :null, // Base directory.
server :false, // Server mode: same as noGui=true and closeTimout=0
sslDir :null, // Enable ssl and use certs in this dir.
sslFnCert :'cert.pem',// File name in sslDir of cert.
sslFnKey :'privkey.pem',// File name in sslDir of key.
srcFile :'', // File of code to source inside the Websrv function.
uploadDir :'/tmp', // Upload files go here
timeout :60000, // Set timeout (in ms) to shutdown. This is idle time, unless negative.
timeout :59999, // Set timeout (in ms) to shutdown. This is idle time, unless negative.
trace :false, // Tracing output.
udata :{}, // Shortcut add of udata to wsOpts.
uploadDir :'/tmp', // Upload files go here
url :"", // The file/url to serve out and clears timeout.
urlPrefix :'', // Prefix for urls
urlUnknown :'', // Url to redirect 404 to.
urlFallback :'', // File-url to serve out if page not found.
useridPass :'', // USER:PASS for web GUI.
vueConvert :false, // Util to convert file .vue files to .js, output in -rootdir
wsdebug :0, // Debug option for websockets.
Expand Down Expand Up @@ -430,7 +432,7 @@ function Websrv(args:string|array, conf:object=void)
if (!File.exists(self.wsinc))
self.wsinc = '';
}
if (self.timeout != options.timeout)
if (self.timeout == options.timeout)
self.timeout = 0;
} if (self.docs) {
if (self.rootdir || self.zip)
Expand All @@ -441,13 +443,13 @@ function Websrv(args:string|array, conf:object=void)
else if (File.isdir(sd) && File.exists(sd+'/'+surl))
self.rootdir = self.docs;
else
throw('-docs must be a docs dir or "/"'+self.docs);
throw('expected docs dir or "/" in -docs '+self.docs);
if (!self.wsinc) {
self.wsinc = self.rootdir+'/docs/wsinc.jsi';
if (!File.exists(self.wsinc))
self.wsinc = '';
}
if (self.timeout != options.timeout)
if (self.timeout == options.timeout)
self.timeout = 0;


Expand Down Expand Up @@ -476,6 +478,8 @@ function Websrv(args:string|array, conf:object=void)
}
if (!self.rootdir)
self.rootdir = '.';
if (self.hist && !self.urlFallback)
self.urlFallback = self.url;

// Provide default values for websocket.
var wopts = self.wsopts = {
Expand All @@ -491,8 +495,9 @@ function Websrv(args:string|array, conf:object=void)
onFilter:WsFilter,
port:self.port,
rootdir:self.rootdir,
urlPrefix:self.urlPrefix,
urlUnknown:self.urlUnknown,
urlPrefix:(self.urlPrefix?self.urlPrefix:null),
urlUnknown:(self.urlUnknown?self.urlUnknown:null),
urlFallback:(self.urlFallback?self.urlFallback:null),
sslCert:self.sslcert,
sslKey:self.sslkey,
ssl:self.ssl,
Expand All @@ -512,7 +517,7 @@ function Websrv(args:string|array, conf:object=void)
if (!self.app && !self.docs)
throw('mod "'+self.mod+'" not one of: admin, menu');
}
if (urlOrig!=='' && self.timeout === 60000)
if (urlOrig!=='' && self.timeout === options.timeout)
self.timeout = 0;
if (!self.app && !self.docs && !self.server && !self.pageStr && self.mod === '' && urlOrig=='' && (!self.url || !File.exists(self.rootdir+'/'+self.url)))
throw("url file empty or not found: "+self.url);
Expand All @@ -523,7 +528,7 @@ function Websrv(args:string|array, conf:object=void)
wopts.noCompress = true;
if (self.server) {
self.noGui = true;
if (self.timeout !== options.timeout)
if (self.timeout == options.timeout)
self.timeout = 0;
} else if (!self.noReload)
wopts.onModify = onModify;
Expand Down Expand Up @@ -551,7 +556,7 @@ function Websrv(args:string|array, conf:object=void)
OpenWebsock();
// if (!self.ws.conf('extHandlers'))
// self.ws.handler('vue', ConvertVue); // VUE BUILTIN NOW
LogTrace("Listening on port:",self.port);
LogTrace("Listening on port:",wsopts.port);

if (!self.noGui && self.url && self.url.length) {
OpenBrowser(self.url, self.anchor, self.query);
Expand Down
7 changes: 2 additions & 5 deletions lib/web/docs/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ body {
color:#222;
}

#jsi-sidebar a.active, #jsi-toc a.active, jsi-left-menu a.active, {
#jsi-sidebar a.active, #jsi-toc a.active, jsi-left-menu a.active,
.nav-link.active, .nav-item span.active {
color:#000;
font-weight:bold;
}
.nav-link {
cursor:pointer;
color:#222;
}
.nav-link.active {
color:#000;
font-weight:bold;
}

.bd-sidebar {
position: -webkit-sticky;
Expand Down
32 changes: 20 additions & 12 deletions lib/web/docs/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jsi docs viewer
function dputs() {};
//dputs = puts;
//var dputs = console.log;

import Vuex from '../js/vuex.js';
Vue.use(Vuex)
Expand Down Expand Up @@ -29,7 +29,7 @@ Vue.component('jsi-nav-bar', {
<b-nav-form class="d-inline-flex" class="visible">
<b-nav-item id="pdq_menubut2" :class="menuClass" style="margin-bottom:-3px" v-b-toggle.jsi_sidebar>&#9776;</b-nav-item>
<b-button size="sm" class="my-2 my-sm-0" class="pdq-nav-area"><a :href="s_navBut.href" target="_blank" :title="s_navBut.title">{{s_navBut.label}}</a></b-button>
<b-button size="sm" class="my-2 my-sm-0" class="pdq-nav-area"><a :href="s_project.href" target="_blank" :title="s_project.title">{{s_project.label}}</a></b-button>
</b-nav-form>
<b-nav-item v-for="(r,i) in s_navFns" :keys="i" href="#" @click="goTo(r+'.md')" :disabled="s_mdFile==r+'.md'" >{{r}}</b-nav-item>
</b-navbar-nav>
Expand All @@ -42,7 +42,7 @@ Vue.component('jsi-nav-bar', {
<b-form-datalist id="docs-search-list" :options="s_searchList" />
<b-button size="sm" class="my-2 my-sm-0" @click="submit" :disabled="searchButDis">Search</b-button>
</b-submit>
<b-button size="sm" class="w-1 bd-submenus" title="Submenu toggle-all" @click="subChange" v-html="subShowLabel"></b-button>
<b-button size="sm" class="w-1 bd-submenus" title="Expose-all submenus in page toggle" @click="subChange" v-html="subShowLabel"></b-button>
</b-nav-form>
<b-nav-form class="d-inline-flex" id="pdq-popover-target-1">
</b-nav-form>
Expand Down Expand Up @@ -114,7 +114,7 @@ Vue.component('jsi-nav-bar', {
},
computed: {
...Vuex.mapState('Docs', ['s_searchList', 's_mdIndex', 's_showAllSub', 's_mdFile', 's_login', 's_websock',
's_navFns', 's_navBut']),
's_navFns', 's_project']),
showMenu() { return this.s_websock },
menuClass() { return (this.s_websock ? "" : 'smalldev'); },
searchDis() { return (this.s_searchList.length==0); },
Expand Down Expand Up @@ -339,7 +339,8 @@ let DocsView = {
methods: {
...Vuex.mapMutations('Docs', ['update_s_dirty', 'update_s_mdToc', 'update_s_mdAncs', 'update_s_curAnc',
'update_s_ancChain', 'update_s_curAncParent', 'update_s_mdFile', 'update_s_fileMod',
'update_s_mdList', 'update_s_mdIndex', 'update_s_searchList', 'update_s_server']),
'update_s_mdList', 'update_s_mdIndex', 'update_s_searchList', 'update_s_server',
'update_s_project', 'update_s_navFns']),

doLoadFile(path, hash, from) {
let cr = this.$route;
Expand Down Expand Up @@ -604,7 +605,7 @@ let DocsView = {
this.update_s_mdIndex(src);
let slst = [], svals = src.sections;
if (src.navBut)
this.update_s_navBut(src.navBut);
this.update_s_project(src.navBut);
if (src.navFns)
this.update_s_navFns(src.navFns);
for (var f in svals) {
Expand Down Expand Up @@ -663,7 +664,14 @@ let DocsView = {

/*============= CODE ===============*/

let histmode = (location.port<=999); // TODO: config it.
let isfossil = $jsi.isfossil();
let sess = $jsi.getCookie('sessionJsi'), iflags = 0, uflags = 0;
if (sess && !isfossil) {
var ssp = sess.split('.');
iflags = parseInt(ssp[1]);
uflags = parseInt(ssp[2]);
}
let histmode = ((iflags&1) || location.port<=999 || location.protocol=='https');

let store = new Vuex.Store({
state: {},
Expand All @@ -684,16 +692,16 @@ let DocsStore = {
s_searchList:[],
s_server:null,
s_websock:null,
s_isfossil:$jsi.isfossil(),
s_isfossil:isfossil,
s_isjsi:$jsi.isjsi(),
s_curAnc:0,
s_curAncParent:-1,
s_ancChain:[],
s_fileMod:null,
s_dirty:false,
s_showAllSub:false,
s_navFns:['Start', 'Reference', 'Index'],
s_navBut:{ label:'JSI', title:"jsish.org home page", href:"https://jsish.org" },
s_navFns:[],
s_project:{ label:'JSI', title:"home page jsish.org", href:"https://jsish.org" },


},
Expand All @@ -704,8 +712,8 @@ let DocsStore = {
update_s_curAnc(state, val) { state.s_curAnc = val; },
update_s_mdList(state, val) { state.s_mdList = val; },
update_s_mdIndex(state, val) { state.s_mdIndex = val; },
update_s_navFns(state, val) { state.navFns = val; },
update_s_navBut(state, val) { state.s_navBut = val; },
update_s_navFns(state, val) { state.s_navFns = val; },
update_s_project(state, val) { state.s_project = val; },
update_s_searchList(state, val) { state.s_searchList = val; },
update_s_server(state, val) { state.s_server = val; },
update_s_websock(state, val) { state.s_websock = val; },
Expand Down
8 changes: 4 additions & 4 deletions lib/web/md/Builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ During the build it will download:

Predefined configurations from **Configs/** can be made using:
```
make clean all CONF=static
make remake CONF=static
```

Available values for `CONF` are: **default devel memdebug minimal musl muslssl noext release static win winssl**
Expand All @@ -54,7 +54,7 @@ Jsi can be cross compiled from Linux to Windows using the Mingw32 package:

``` bash
sudo apt-get install gcc-mingw-w64
make clean all CONF=win
make remake CONF=win
```

**Warning**: Features such as signals are disabled in the Windows build.
Expand All @@ -68,7 +68,7 @@ This is useful when you need an executable with no external dependancies.

``` bash
sudo apt-get install musl-tools
make clean all CONF=musl
make remake CONF=musl
```


Expand All @@ -85,7 +85,7 @@ gmake
To build with SSL support use the provided configs **muslssl** / **winssl**, or:

``` bash
make WITH_SSL=1 clean all
make remake WITH_SSL=1
```


Expand Down
4 changes: 1 addition & 3 deletions lib/web/md/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ Index
| [Testing](Testing.md) | Builtin test support | [Logging](Logging.md) | Logging support |
| [Reference](Reference.md) | Command reference | [Debug](Debug.md) | Debugging in Jsi |


### Advanced

|----------------------------|-----------------------|---------------------------|--------------------------------|
| DOC | DESCRIPTION | DOC | DESCRIPTION |
|----------------------------|-----------------------|---------------------------|--------------------------------|
| [Extensions](Extensions.md)| Rolling C extensions | [Builds](Builds.md) | Advanced build topics |
Expand Down
12 changes: 1 addition & 11 deletions lib/web/md/Misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,6 @@ Compiling as C++ is supported, mostly for integrity checks.
**Note**:
C-integration is the main priority in Jsi, not speed of script execution.

## Shortcomings

Following is a partial list of things that are either incomplete or unimplemented:

- Creation of a complete test suite for code-coverage.
- Run applications directly from fossil.
- A PostgreSql extension.
- Extension for libmicrohttpd for use in post.
- Support for libevent/libev.


## Rational

Expand Down Expand Up @@ -747,7 +737,7 @@ Building SSL

How do you build-in SSL support to jsish?

Answer: yes. make WITH_SSL=1 clean all
Answer: yes. make remake WITH_SSL=1

Note: Jsi now uses [lws](https://jsish.org/lws), a fork of LibWebsockets.

Expand Down
4 changes: 3 additions & 1 deletion lib/web/md/Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ Commands for managing WebSocket server/client connections.
|redirMax|*BOOL*|Temporarily disable redirects when see more than this in 10 minutes.||
|rootdir|*STRING*|Directory to serve html from (".").||
|server|*STRKEY*|String to send out int the header SERVER (jsiWebSocket).||
|sessFlag|*INT*|Flag to send in sessionJsi cookie.|initOnly|
|ssiExts|*OBJ*|Object map of file extensions to apply SSI. eg. {myext:true, shtml:false} .|initOnly|
|ssl|*BOOL*|Use https.|initOnly|
|sslCert|*STRKEY*|SSL certificate file.||
Expand All @@ -1160,9 +1161,10 @@ Commands for managing WebSocket server/client connections.
|startTime|*TIME_T*|Time of websocket start.|readOnly|
|includeFile|*STRKEY*|Default file when no extension given (include.shtml).||
|udata|*OBJ*|User data.||
|urlFallback|*STRKEY*|Fallback to serve when file not found..||
|urlPrefix|*STRKEY*|Prefix in url to strip from path; for reverse proxy..||
|urlRedirect|*STRKEY*|Redirect when no url or /, and adds cookie sessionJsi..||
|urlUnknown|*STRKEY*|Redirect for unknown page or 404..||
|urlUnknown|*STRKEY*|Redirect for 404 unknown page..||
|useridPass|*STRKEY*|The USERID:PASSWORD to use for basic authentication.||
|version|*OBJ*|WebSocket version info.|readOnly|
### WebSocket stats
Expand Down
Loading

0 comments on commit fa0ff92

Please sign in to comment.