Closed oliverwehn closed 11 years ago
Cool, thanks a lot.
I was already aware of the URL hash thing, but couldn't come up with a solution. what's your suggestion? can we store usernames as /twitter-times/username
and hashtags as /twitter-times/#hashtag
?
Damn, the two hashtags break Twitter. Links cannot be posted. Need to find sth else.
I'd suggest to just use the url encoded notation of "#": "%23". That should work right away when you add #%23hashtag to the url. So you only have to care for the part of the script, where the string is added to the url.
that works, just implemented it. what about my suggestion to use an url without # for usernames (https://github.com/davidbauer/Twitter-Times/pull/48#issuecomment-11931719). complicated?
The problem is, that the browser will show an 404 error as you'd have to change document.location.href. It would cause a new request being sent to the server with the modified url. You could catch this with a server-side url rewrite. But as soon as you add change the hash, the hash would be added to the current url. For example, when you searched for your Tweets right before, the url would be changed to labs.davidbauer.ch/twitter-times/davidbauer. When you would search for #hashtag now, the url shown in the address bar would be labs.davidbauer.ch/twitter-times/davidbauer#hashtag. The results shown would be technically correct, but in my opinion it would be far from optimal to create a misleading url this way.
Snap. Right, that's not a good solution. Can you think of a more elegant solution than the current one?
As the hash is the only thing you can change without triggering a reload afaik, I just see the option of replacing or encoding the "#" or adding usernames with a "#@" prepended to it to the url treating everything else as a hashtag.
I just realized that there is an issue with Firefox, when you call the url with hash directly, like http://labs.davidbauer.ch/twitter-times/#%2329c3. It seems to treat the hashtag input as a username. I'll have a look at this.
Your second version of the hashtag query was the right one. The url of your ajax call was just missing the callback parameter to force the response data to be delivered jsonp style. Just like you already use it in your username query.
Also the response data is layed out in a different way when you query via the search api. So the Tweets are stored in an array within the returned json object (in data.results).
So, it should work now.
BTW: Storing the current search phrase as hash added to the url breaks as soon as you try to store a hashtag this way. So I'd suggest to encode hashtags somehow before adding them to the url in the address bar.