WardCunningham / Smallest-Federated-Wiki

This wiki innovates by: 1. federated sharing, 2. drag refactoring and 3. data visualization.
http://wardcunningham.github.com/
GNU General Public License v2.0
1.21k stars 178 forks source link

Story Serialization - issues with expression as URL #412

Open paul90 opened 10 years ago

paul90 commented 10 years ago

The current way the current view into a federation is presented as a URL presents a few issues.

There are two types entry points, URLs like http://fed.wiki.org/welcome-visitors.html, and http://fed.wiki.org/view/welcome-visitors/plugins.fed.wiki.org/about-plugins. http://fed.wiki.org/ is redirected to http://fed.wiki.org/welcome-visitors.html.

Re-writing the URL has a knock-on effect that an intelligent server is required, the URL does not point directly to a resource that a dumb server can serve. This acts as a barrier to using a cheap 'dumb' server to publish a public view of a private federation, part of #410. Creation of a static server entails saving content (page json, sitemap, etc…), together with the client, in the locations that the client expects to find them.

Some additional issues:

A Proposal

Use fragment identifier, to separate the origin from the list of pages in the lineup. Pages within the lineup being separated with :. For example:

Where the page is from a server other than the origin, we need to indicate the page-name together with the FQDN, using = as a separator. For example:

Server rendered pages retain the http://fed.wiki.org/welcome-visitors.html scheme, and the client must not re-write the URI, or re-render the page. The client should be able to configure link behaviour, so able to explore the federation as a series of static pages without needing to disable javascript.

WardCunningham commented 10 years ago

This advice comes at a very good time. My own summary of server classes ends with the realization:

I've come to this realization in my work with @1337807 on a minimalist federated wiki server in Go where we attempt to stay within core modules and Go centric idioms. Parsing /view/slug/view/slug has been clearly a mis-fit even in this very modern programming environment.

egonelbre commented 9 years ago

Just noticed the Go problem you were having, you can parse /view/alpha/view/beta with

func handler(rw http.ResponseWriter, req *http.Request) {
    tokens := strings.Split(req.URL.Path, "/")[1:]
    // tokens[0] == "view"
    // tokens[1] == "alpha"
    // tokens[2] == "view"
    // tokens[3] == "beta"
}

req.URL.Path contains the pathname as a regular string so you can split/parse it as needed.

WardCunningham commented 9 years ago

Good point. We were a little too attached to regex routing since that is what we had been doing in Sinatra. We do want the added validation provided by regex in the Factory drop logic but that is in the client where it is well supported.

egonelbre commented 9 years ago

There are plenty of different routers that provide different features (e.g. (http://www.gorillatoolkit.org/pkg/mux, https://github.com/bmizerany/pat, and even more https://github.com/vishr/go-http-routing-benchmark). Of course, implementing your own router is trivial https://play.golang.org/p/lXRFobL4GJ (note, code untested and can be made nicer).

WardCunningham commented 9 years ago

Yes, we went down the custom router route. It became more complicated than the rest of the server. I had to stop and ask, what is it about wiki that requires this complexity. My conclusion: nothing. Hence my desire to simplify.