Permalink
Browse files

Move save/ignore links to bottom

So that you can only get to them by going through all the stories on
the page and deter from accidental or rash clicking.
  • Loading branch information...
lovett committed Sep 1, 2015
1 parent 3a1e505 commit f6534c2dd028691cd567da32633cbff1bfffd57a
Showing with 146 additions and 19 deletions.
  1. +128 −6 main.js
  2. +18 −13 ui/index.html
View
134 main.js
@@ -1,6 +1,11 @@
-var dispatcher = require('./dispatcher');
-var fs = require('fs');
-var runInterval = 10 * 1000; // 10 seconds
+'use strict';
+
+var bunyan, db, dispatcher, env, fs, logger, sqlite3;
+
+bunyan = require('bunyan');
+dispatcher = require('./dispatcher');
+fs = require('fs');
+sqlite3 = require('sqlite3');
/**
* Environment variables
@@ -9,7 +14,6 @@ var runInterval = 10 * 1000; // 10 seconds
* If the file env.json exists, declare its contents as environment
* variables.
*/
-var env;
try {
env = fs.readFileSync('env.json', {encoding: 'utf8'});
@@ -22,7 +26,125 @@ try {
console.log(e);
}
-dispatcher.autoload();
-dispatcher.insist('fetch', [1, 'http://www.reddit.com/r/angularjs/.rss']);
+db = new sqlite3.Database(process.env.HEADLINES_DB_NAME);
+
+if (process.env.HEADLINES_LOG) {
+ logger = bunyan.createLogger({
+ name: 'headlines',
+ streams: [
+ {
+ path: 'test.log',
+ level: process.env.HEADLINES_LOG_LEVEL || 'trace'
+ }
+ ]
+ });
+}
+
+dispatcher.on('feed:subscribe:done', function () {
+ dispatcher.emit('filter:store', db, {
+ feedId: 1,
+ userId: 1,
+ value: 'title contains authentication',
+ weight: -1
+ });
+ dispatcher.emit('filter:store', db, {
+ feedId: 1,
+ userId: 1,
+ value: 'title contains iphone',
+ weight: -2
+ });
+ dispatcher.emit('filter:store', db, {
+ feedId: 1,
+ userId: 1,
+ value: 'comments > 200',
+ weight: 5
+ });
+});
+
+dispatcher.once('filter:store:done', function () {
+ console.log('Added filter');
+ dispatcher.insist('poll', db);
+});
+
+
+dispatcher.on('poll:done', function () {
+ console.log('Poll is complete');
+});
+
+dispatcher.on('fetch:done', function (feed) {
+ feed.type = 'fetch';
+ dispatcher.insist('history:add', db, feed);
+
+ if (feed.status >= 301 && feed.status <= 303 && feed.headers.hasOwnProperty('location')) {
+ dispatcher.insist('feed:update', db, {
+ id: feed.id,
+ url: feed.headers.location
+ });
+ }
+});
+dispatcher.on('entry', function (entry) {
+ dispatcher.insist('entry:store', db, entry);
+});
+
+dispatcher.on('discussion', function (discussion) {
+ dispatcher.insist('discussion:store', db, discussion);
+});
+
+dispatcher.on('log', function (level, message, fields) {
+ if (level === 'trace') {
+ return;
+ }
+ console.log(message, fields || '');
+});
+
+
+/*dispatcher.once('unlisten:done', function (params) {
+ console.log('unlistened to', params.event);
+});*/
+
+dispatcher.once('setup:done', function () {
+
+ db.run('INSERT OR IGNORE INTO users (username, passwordHash) VALUES ("test", "test")', function (err) {
+ if (err) {
+ throw err;
+ }
+
+ dispatcher.insist('feed:subscribe', db, {
+ url: 'http://localhost/~blovett/slashdot.rdf',
+ userId: this.lastID
+ });
+
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://localhost/~blovett/debian.rdf',
+ userId: this.lastID
+ });*/
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://localhost/~blovett/lobster.rss',
+ userId: this.lastID
+ });*/
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://httpbin.org/redirect-to?url=http://example.com',
+ userId: this.lastID
+ });*/
+
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://localhost/~blovett/google-drive.atom',
+ userId: this.lastID
+ });*/
+
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://emacs.stackexchange.com',
+ userId: this.lastID
+ });*/
+
+ /*dispatcher.insist('feed:subscribe', db, {
+ url: 'http://www.reddit.com/r/angularjs/.rss',
+ userId: this.lastID
+ });*/
+ });
+});
+
+dispatcher.autoload();
+dispatcher.insist('setup', db);
View
@@ -14,6 +14,23 @@ <h1 class="appname">Headlines</h1>
</div>
<ul class="right panel" ng-show="user.loggedIn" ng-cloak>
+ <li><a ng-class="{active: listName == 'unread'}" href="/entries/unread/">Unread</a></li>
+ <li><a ng-class="{active: listName == 'saved'}" href="/entries/saved/">Saved</a></li>
+ <li><a ng-class="{active: listName == 'feeds'}" href="/feeds">Feeds</a></li>
+ <li><a href="/logout">Log out</a></li>
+ </ul>
+ </nav>
+
+ <div ng-show="showPager" class="pager flex-wrapper">
+ <div ng-class="{hidden: page == 1}"><a href="{{ prevLink }}">Previous Page</a></div>
+ <div class="current">Page {{ page }} of {{ pageCount }}</div>
+ <div ng-class="{hidden: page == pageCount}"><a href="{{ nextLink }}">Next Page</a></div>
+ </div>
+
+ <main ng-view></main>
+
+ <nav class="nav-bar">
+ <ul class="right panel" ng-show"user.loggedIn" ng-cloak>
<li ng-show="listName == 'unread' && listSize > 0">
<a href="#" class="action" ng-click="setEntryState('saved')">
Save
@@ -28,21 +45,9 @@ <h1 class="appname">Headlines</h1>
<span ng-show="savedCount == 0">all</span>
</a>
</li>
- <li><a ng-class="{active: listName == 'unread'}" href="/entries/unread/">Unread</a></li>
- <li><a ng-class="{active: listName == 'saved'}" href="/entries/saved/">Saved</a></li>
- <li><a ng-class="{active: listName == 'feeds'}" href="/feeds">Feeds</a></li>
- <li><a href="/logout">Log out</a></li>
- </ul>
+ </ul
</nav>
- <div ng-show="showPager" class="pager flex-wrapper">
- <div ng-class="{hidden: page == 1}"><a href="{{ prevLink }}">Previous Page</a></div>
- <div class="current">Page {{ page }} of {{ pageCount }}</div>
- <div ng-class="{hidden: page == pageCount}"><a href="{{ nextLink }}">Next Page</a></div>
- </div>
-
- <main ng-view></main>
-
<div id="screen-size">
<span class="show-for-small-only"></span>
<span class="show-for-medium-only"></span>

0 comments on commit f6534c2

Please sign in to comment.