davidbauer / Instacurate

Turn your Twitter timeline into a personalised news site, in an instant. Fetches links from your timeline and displays them in a discovery friendly design.
http://www.instacurate.com
113 stars 29 forks source link

Fixed your issue with search by hashtag. #48

Closed oliverwehn closed 11 years ago

oliverwehn commented 11 years ago

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.

davidbauer commented 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?

davidbauer commented 11 years ago

Damn, the two hashtags break Twitter. Links cannot be posted. Need to find sth else.

oliverwehn commented 11 years ago

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.

davidbauer commented 11 years ago

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?

oliverwehn commented 11 years ago

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.

davidbauer commented 11 years ago

Snap. Right, that's not a good solution. Can you think of a more elegant solution than the current one?

oliverwehn commented 11 years ago

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.