I'm building a site and I would like to allow users to create and account,
and I would like them to have an option to use whitespaces in their handle.
Apparently I am doing something way wrong here, so it is possible that I
messed up something somewhere else.
When I create a user, for example
What are url-encode and url-decode doing wrong? They look like they
should work (e.g.
https://github.com/ring-clojure/ring-codec/blob/master/test/ring/util/test/codec.clj#L21).
On 25 February 2014 07:14, David Toomey wrote:
> I'm building a site and I would like to allow users to create and accou
You can use the default Java classes which are available:
=> (-> (java.net.URI. "http" "www.mysite" "/some user" nil) .toURL
.toString)
"http://www.mysite/some%20user";
=>
ring-codec is easy too:
(https://github.com/ring-clojure/ring-codec)
=> (str "www.mysite/" (ring.util.codec/url-encode "som
Thanks for the repiles -- and sorry for the delayed reply. I guess I'm
doing something obnoxiously stupid.
The code I'm working with looks like this:
(GET "/:profile-page" [profile-page]
. ;;; check if user is in database, if so, show the profile
page: ))
I've tried several
You should be able to write:
(GET "/:profile-page" [profile-page] ...)
Compojure (via Clout) automatically decodes parameters in the URL, so there
shouldn't be any need to decode the data any further.
However, for future reference, routes in Compojure have a syntax very
similar to functions.
You should be able to write:
(GET "/:profile-page" [profile-page] ...)
Compojure (via Clout) automatically decodes parameters in the URL, so there
shouldn't be any need to decode the data any further.
Heh, I would have thought something was baked in, but I still get urls with
nothing filli
This has become super confusing to follow, possibly because you have the
wrong expectation of compojure?
Compojure is not specificy how your routes will look, it is responding to
whatever URLs you put in place.
In the case of:
(GET "/:profile-page" [profile-page] ...)
:profile-page in the rou
Fair enough. So if I want pretty urls, I have to have an extra column in my
database then. This is one compromise, but I was hoping for something a
little more programmatic.
As a counter to G+, StackOverflow alters the name to lower-case and add a
'-', so that M User becomes www./m-user.
Right, either way the compojure route would be the same. (GET
"/:profile-name" [profile-name] ...).
You don't need an extra column in your DB unless you want to do so.
The route/compojure is simply responding to the URL you write out in your
template, or that is requested by some other mecha
No edit button so I have to post again, that first example should end with
";; (make-profile-url "John Smith") => "/John-Smith"
And to reiterate you decide what your url will look like in your template:
http://myapp.com/JohnSmith";>View John Smith's Profile
or
http://myapp.com/John-Smith";>View
Yes, that certainly did help. Can't believe I didn't see this and it still
flew over my head when others pointed it out.
Looks a bit hacky, but this is the result I came up with (for future
person's reference):
(GET "/:profile-page" [profile-page]
(if (= (.indexOf profile-page " ") -
11 matches
Mail list logo