couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Broerse <i...@martinbroerse.com>
Subject Re: pushState in CouchDB for Ember
Date Tue, 27 Oct 2015 07:34:38 GMT
Hi Ingo,

It seems there is no 404 rewrite possible. But thanks to you I got it
working:

https://martinic.cloudant.com/bloggrtest/_design/bloggrtest/_rewrite/

My rewrites.json

[
   {
       "from": "/",
       "to": "index.html",
       "method": "GET"
   },
   {
       "from": "/*",
       "to": "/*",
       "method": "GET"
   },
   {
       "from": "/posts/*",
       "to": "index.html",
       "method": "GET"
   },
   {
       "from": "/authors/*",
       "to": "index.html",
       "method": "GET"
   },
   {
       "from": "/about/*",
       "to": "index.html",
       "method": "GET"
   }
]

This way it also works for:

https://martinic.cloudant.com/bloggrtest/_design/bloggrtest/_rewrite/crossdomain.xml

I will test if something like this will work.

 {
       "from": "/*/*",
       "to": "index.html",
       "method": "GET"
   },

 Perhaps add assets and fonts again above this.

- Martin

On Sun, Oct 25, 2015 at 11:16 PM, Ingo Radatz <thewhorn@googlemail.com>
wrote:

> Hi Martin,
>
> good news! - i have a local copy of your application up and running. Btw.
> my fan is freaking out - some of our reloading code causes heavy load but
> anyway - here is what you have to do:
>
> # 1st - to use the rewrite handler your root url is
>
> https://martinic.cloudant.com/bloggttest/_design/bloggrtest/_rewrite
>
> You can use your custom API from the rewrites.json in parallel with
> CouchDB’s native API - but you must remember when is which API in use.
>
>
> # 2nd - change the root URL in your index.html base-url meta tag
>
> <base href="/bloggttest/_design/bloggrtest/_rewrite/" />
>
>
> # 3th - extend the rewrites.json as follows
>
> [
>    {
>        "from": "fonts/*",
>        "to": "fonts/*",
>        "method": "GET"
>    },
>    {
>        "from": "assets/*",
>        "to": "assets/*",
>        "method": "GET"
>    },
>    {
>        "from": "/",
>        "to": "index.html",
>        "method": "GET"
>    }
> ]
>
>
> Now, your app will start when you request
>
> https://martinic.cloudant.com/bloggttest/_design/bloggrtest/_rewrite/
>
> in the browser. Your router forwards via pushState functionality to /posts
> and i can choose particular posts like
> /posts/7DFFB605-62CD-9D72-B376-5D3729E21904.
>
> And now i want to draw a line. Nothing of this enables
> "pushState-on-CouchDB”. It would work also without the CouchDB rewrite
> rules. But now comes the part where you want that to allow your readers to
> bookmark a blog post e.g.
>
>
> https://martinic.cloudant.com/bloggttest/_design/bloggrtest/_rewrite/posts/7DFFB605-62CD-9D72-B376-5D3729E21904
>
> When they load this bookmark they will get:
>
> {"error":"not_found","reason":"missing”}
>
> Now you can add the following rule to the rewrites.json
>
>    {
>        "from": “/posts/*",
>        "to": "index.html",
>        "method": "GET"
>    }
>
> It will always deliver the same index.html. Your ember router must know
> the real root url and match to the route /posts/:id. The router have to act
> the same way automatically in the initial load as i have manually by
> clicking your blog post link.
>
>
> Hope that helps.
> Ingo
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message