aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-01-30 18:43:29 -0800
committerAdam Mathes <adam@trenchant.org>2017-01-30 18:43:29 -0800
commit09a859501fc1fb1f4f781cfdd448f359b7ef4983 (patch)
tree08d5e0e942b88d47e5799c406de640f49c305756
parent030cfcce60658ede58a31b36704a3a417c346a4c (diff)
downloadneko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.tar.gz
neko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.tar.bz2
neko-09a859501fc1fb1f4f781cfdd448f359b7ef4983.zip
add back in starred functionality, fix login page
-rw-r--r--init.sql1
-rw-r--r--models/item/item.go16
-rw-r--r--static/login.html6
-rw-r--r--static/ui.js8
-rw-r--r--web/web.go7
5 files changed, 21 insertions, 17 deletions
diff --git a/init.sql b/init.sql
index 7b01fda..d050359 100644
--- a/init.sql
+++ b/init.sql
@@ -16,6 +16,7 @@ CREATE TABLE item (
description TEXT,
publish_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
read_state BOOLEAN DEFAULT FALSE NOT NULL,
+ starred BOOLEAN DEFAULT FALSE NOT NULL,
FOREIGN KEY (feed_id) REFERENCES feed(id) ON DELETE CASCADE,
UNIQUE KEY (url),
INDEX (publish_date),
diff --git a/models/item/item.go b/models/item/item.go
index 51166c4..3cf8a19 100644
--- a/models/item/item.go
+++ b/models/item/item.go
@@ -14,6 +14,7 @@ type Item struct {
Url string `json:"url"`
Description string `json:"description"`
ReadState bool `json:"read"`
+ Starred bool `json:"starred"`
FeedId int64
PublishDate string `json:"publish_date"`
FeedTitle string `json:"feed_title"`
@@ -42,8 +43,8 @@ func (i *Item) Create() error {
func (i *Item) Save() {
_, err := models.DB.Exec(`UPDATE item
- SET read_state=?
- WHERE id=?`, i.ReadState, i.Id)
+ SET read_state=?, starred=?
+ WHERE id=?`, i.ReadState, i.Starred, i.Id)
if err != nil {
log.Println(err)
}
@@ -58,12 +59,12 @@ func (i *Item) FullSave() {
}
}
-func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
+func Filter(max_id int64, feed_id int64, unread_only bool, starred_only bool) ([]*Item, error) {
var args []interface{}
query := `SELECT item.id, item.title, item.url, item.description,
- item.read_state, item.publish_date,
+ item.read_state, item.starred, item.publish_date,
feed.url, feed.title
FROM item,feed
WHERE item.feed_id=feed.id `
@@ -82,6 +83,11 @@ func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
query = query + " AND item.read_state=0 "
}
+ if starred_only {
+ query = query + " AND item.starred=1 "
+ }
+
+
query = query + "ORDER BY item.id DESC LIMIT 15"
// log.Println(query)
// log.Println(args...)
@@ -102,7 +108,7 @@ func Filter(max_id int64, feed_id int64, unread_only bool) ([]*Item, error) {
items := make([]*Item, 0)
for rows.Next() {
i := new(Item)
- err := rows.Scan(&i.Id, &i.Title, &i.Url, &i.Description, &i.ReadState, &i.PublishDate, &i.FeedUrl, &i.FeedTitle)
+ err := rows.Scan(&i.Id, &i.Title, &i.Url, &i.Description, &i.ReadState, &i.Starred, &i.PublishDate, &i.FeedUrl, &i.FeedTitle)
if err != nil {
log.Println(err)
return nil, err
diff --git a/static/login.html b/static/login.html
index d97c831..ab3e781 100644
--- a/static/login.html
+++ b/static/login.html
@@ -3,11 +3,6 @@
<head>
<title>neko rss mode</title>
<link rel="stylesheet" href="/static/style.css" />
- <script src="/static/jquery.min.js"></script>
- <script src="/static/jquery.tmpl.min.js"></script>
- <script src="/static/underscore.min.js"></script>
- <script src="/static/backbone.min.js"></script>
- <script src="/static/ui.js"></script>
<meta name="viewport" content="width=device-width" />
<meta name="viewport" content="initial-scale=1.0" />
</head>
@@ -19,7 +14,6 @@
<h3>password</h3>
<input type="password" name="password">
-
<input type="submit" name="login">
</form>
diff --git a/static/ui.js b/static/ui.js
index 96e285d..6f44db0 100644
--- a/static/ui.js
+++ b/static/ui.js
@@ -224,9 +224,6 @@ var ItemCollection = Backbone.Collection.extend({
App.loading = true;
url = '/stream/';
- if(App.get('starredFilter')) {
- url = url + 'starred/';
- }
if(App.tag != undefined) {
url = url + 'tag/' + App.tag + '/';
}
@@ -234,11 +231,12 @@ var ItemCollection = Backbone.Collection.extend({
if(App.get('searchFilter')) {
url = url + '&q=' + App.get('searchFilter');
}
-
if(App.get('feedFilter')) {
url = url + '&feed_url=' + App.get('feedFilter').get('url');
}
-
+ if(App.get('starredFilter')) {
+ url = url + '&starred=1';
+ }
if(App.items.last()) {
url = url + '&max_id=' + App.items.last().get('_id');
}
diff --git a/web/web.go b/web/web.go
index 2cb9669..1f01241 100644
--- a/web/web.go
+++ b/web/web.go
@@ -37,8 +37,13 @@ func streamHandler(w http.ResponseWriter, r *http.Request) {
unread_only = false
}
+ starred_only := false
+ if r.FormValue("starred") != "" {
+ starred_only = true
+ }
+
var items []*item.Item
- items, err := item.Filter(int64(max_id), feed_id, unread_only)
+ items, err := item.Filter(int64(max_id), feed_id, unread_only, starred_only)
if err != nil {
log.Println(err)
}