Movatterモバイル変換


[0]ホーム

URL:


Preview server
What is this ?

The preview server watches Stog files and recomputesthe documents when there is a change. This is useful to havea preview as you modify your web site or article.

Have a look at stog server in action on a videohere.

How does it work ?

When launched, the server computes the documents a first time.It then handles HTTP connections. All documents are accessedunder the path/preview/. For example, the/foo/bar.htmldocument will be browsed, by default, at addresshttp://localhost:8080/preview/foo/bar.html.

When a browser queries a document preview, the server returnsa simple page with some javascript code to load. This javascript codeopens a websocket connection, by default tohttp://localhost:8081,and queries the document. The server sends the whole document preview andthe javascript code fills the DOM with the document.

When a source file is modified, the server recomputesthe corresponding documents and sends a patch to the browser,through the websocket connection.The javascript code applies the patch to the DOM.

Applying patches rather than reloading the whole document is betterwhen some parts of the document are changed by some other code(I'm looking at you, Mathjax). By now, this case is not fully handled yet,but this is work in progress. The javascript part oftheXmldifflibrary allows to specify some nodes to ignore when applying a patch.

By now, only documents which exist when the server is launched arewatched for changes. This means that if you add a new document source file,you have to click on the ↺ button at the top of the preview page.

Usage

To run the server, simply runstog-server[.byte] instead ofstog[.byte], with the same parameters.

The--http and--ws command line options can beused to specify a url defining the host and port to listen on, for the HTTPand websocket servers respectively. Defaults arehttp://localhost:8080andws://localhost:8081.

If the server must be run behind a proxy, you must also give the--pub-http and--pub-ws options to indicatethe "public" base urls, i.e. the ones that the proxy will handle to sendqueries to the server.

For information you can see the source code of the page.

<pagetitle="Preview server"with-contents="true"navbar-doc="active"><contents><toc/><sectionid="whatis"title="What is this ?"><p>The preview server watches Stog files and recomputesthe documents when there is a change. This is useful to havea preview as you modify your web site or article.</p><p>Have a look at stog server in action on a video<dochref="2014-10-27-video.html">here</doc>.</p></section><sectionid="how"title="How does it work ?"><p>When launched, the server computes the documents a first time.It then handles HTTP connections. All documents are accessedunder the path<icode>/preview/</icode>. For example, the<icode>/foo/bar.html</icode>document will be browsed, by default, at address<icode>http://localhost:8080/preview/foo/bar.html</icode>.</p><p>When a browser queries a document preview, the server returnsa simple page with some javascript code to load. This javascript codeopens a websocket connection, by default to<icode>http://localhost:8081</icode>,and queries the document. The server sends the whole document preview andthe javascript code fills the DOM with the document.</p><p>When a source file is modified, the server recomputesthe corresponding documents and sends a patch to the browser,through the websocket connection.The javascript code applies the patch to the DOM.</p><p>Applying patches rather than reloading the whole document is betterwhen some parts of the document are changed by some other code(I'm looking at you, Mathjax). By now, this case is not fully handled yet,but this is work in progress. The javascript part ofthe<ext-ahref="http://zoggy.github.io/xmldiff">Xmldiff</ext-a>library allows to specify some nodes to ignore when applying a patch.</p><pclass="alert alert-warning">By now, only documents which exist when the server is launched arewatched for changes. This means that if you add a new document source file,you have to click on the ↺ button at the top of the preview page.</p></section><sectionid="usage"title="Usage"><p>To run the server, simply run<icode>stog-server[.byte]</icode> instead of<icode>stog[.byte]</icode>, with the same parameters.</p><p>The<icode>--http</icode> and<icode>--ws</icode> command line options can beused to specify a url defining the host and port to listen on, for the HTTPand websocket servers respectively. Defaults are<icode>http://localhost:8080</icode>and<icode>ws://localhost:8081</icode>.</p><p>If the server must be run behind a proxy, you must also give the<icode>--pub-http</icode> and<icode>--pub-ws</icode> options to indicatethe "public" base urls, i.e. the ones that the proxy will handle to sendqueries to the server.</p></section></contents></page>
Generated on December 11, 2024 at 17h43

[8]ページ先頭

©2009-2025 Movatter.jp