Пример #1
0
func buildSubscriptions() []Subscription {
	var subscriptions []Subscription
	feeds, _ := db.GetAllFeeds()
	for _, feed := range feeds {
		subscription := Subscription{Title: feed.Title, ID: feed.Name, URL: feed.URL}
		subscriptions = append(subscriptions, subscription)
	}
	return subscriptions
}
Пример #2
0
func Sync() {
	var feedsToUpdate []structure.Feed
	feeds, err := db.GetAllFeeds()
	utils.Checkerr(err)
	for _, feed := range feeds {
		maxTimeSinceUpdate := 24 / feed.ChangeFrequency
		if time.Now().Sub(feed.LastUpdate).Hours() > maxTimeSinceUpdate {
			feedsToUpdate = append(feedsToUpdate, feed)
		}
	}
	processFeeds(feedsToUpdate)
}
Пример #3
0
func apiLatestHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, xml.Header)
	enc := xml.NewEncoder(w)
	feeds, _ := db.GetAllFeeds()
	entries := structure.ExtractEntriesFromFeeds(feeds...)
	filter, _ := db.GetFilter()
	entries = structure.FilterEntries(entries, filter)
	atomfeed := atom.CreateAtomFeed("Latest", "The latest news from your Brooklet subscriptions", "latestbrooklet", "Brooklet", "", time.Now())
	for _, entry := range entries {
		atomfeed.AddEntry(entry.Title, entry.Summary, entry.Content, entry.ID, entry.ID, entry.PermaLink, entry.Author, entry.Twitter, entry.Updated)
	}
	enc.Encode(atomfeed)
}
Пример #4
0
func (c *Cache) SetAll() {
	c.lock.Lock()
	defer c.lock.Unlock()
	feeds, _ := db.GetAllFeeds()
	entries := structure.ExtractEntriesFromFeeds(feeds...)
	filter, _ := db.GetFilter()
	entries = structure.FilterEntries(entries, filter)
	if len(entries) > 100 {
		entries = entries[:100]
	}
	var d Data
	d.timestamp = time.Now()
	d.Title = "All"
	d.Entries = entries
	c.data["all"] = d
}
Пример #5
0
func buildNavigation() Navigation {
	var nav Navigation
	for key, _ := range navigationbase {
		navitem := NavigationItem{Title: key, URL: navigationbase[key]}
		nav.NavigationItems = append(nav.NavigationItems, navitem)
	}
	feeds, _ := db.GetAllFeeds()
	var sublist SubList
	for _, feed := range feeds {
		subitem := SubItem{Title: feed.Title, URL: "/feed/" + feed.Name, Icon: feed.Icon}
		sublist.SubItems = append(sublist.SubItems, subitem)
	}
	nav.NavigationItems = append(nav.NavigationItems, NavigationItem{Title: "Subscriptions", SubList: sublist})
	nav.NavigationItems = SortNavigationItems(nav.NavigationItems)
	return nav
}