Hi,
This is going to be a two-step process for you. Your app now does two things:
1. Track tweets and save them to DB.
2. On rendering Index page, displays those tweets.
You want to change the following:
- change the tracking keyword based on url
- fetch only such keyworded tweets.
The first part is simple.
Instead of the part:
app.get('/', routes.index), you will have app.get('/:keyword', routes.keywordIndex);
And the routes.keywordIndex is a function that starts loading only functions by that keyword
You will have to alter the tweet model slightly:
- add a 'keyword' property (and save it from that nTwitter stream, along with tweet data).
- add a keyword parameter to Tweet.getTweets that will only search such tweets. (And take it into account with paging.
Then alter the bottom part of server.js - instead of starting to fetch right away, put the twit.stream(...) in a function that will take a keyword. It will only start running (fetching stream) as you call this function from route handler.
I think that nTwitter can only be used for one stream given one API key, but not sure on that. Check it yourself, and if it's true, this will be a single-user app :)
Here, I've given you one possible plan, but it's on you to start hacking into details, and hit stackoverflow when stuck.