Refactor app in to its own slice
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Blogroll
|
||||
class Index < Adamantium::View
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,27 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Blogroll
|
||||
class List < Adamantium::View
|
||||
config.layout = false
|
||||
|
||||
include Deps[blogroll_list: "queries.blogroll.index"]
|
||||
|
||||
expose :blogroll do |blogroll_result|
|
||||
JSON.parse(blogroll_result)["subscriptions"].map do |feed|
|
||||
{
|
||||
title: feed["title"],
|
||||
url: feed["url"],
|
||||
html_url: feed["htmlUrl"],
|
||||
icon: feed["iconUrl"],
|
||||
categories: feed["categories"].map {|cat| cat["label"]}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private_expose :blogroll_result do
|
||||
blogroll_list.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,25 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Blogroll
|
||||
class Opml < Adamantium::View
|
||||
include Deps[blogroll_list: "queries.blogroll.index"]
|
||||
|
||||
expose :blogroll do |blogroll_result|
|
||||
JSON.parse(blogroll_result)["subscriptions"].map do |feed|
|
||||
{
|
||||
title: feed["title"],
|
||||
url: feed["url"],
|
||||
html_url: feed["htmlUrl"],
|
||||
icon: feed["iconUrl"],
|
||||
categories: feed["categories"].map {|cat| cat["label"]}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private_expose :blogroll_result do
|
||||
blogroll_list.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,19 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Bookmarks
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :bookmarks do |query:|
|
||||
post_repo.bookmark_listing(query: query).map do |bookmark|
|
||||
Decorators::Bookmarks::Decorator.new bookmark
|
||||
end
|
||||
end
|
||||
|
||||
expose :q do |query:|
|
||||
query
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,30 +0,0 @@
|
||||
require "ogpr"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Bookmarks
|
||||
class Metadata < View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
config.layout = nil
|
||||
|
||||
expose :description do |og_data|
|
||||
og_data.description
|
||||
end
|
||||
|
||||
expose :title do |og_data|
|
||||
og_data.title
|
||||
end
|
||||
|
||||
expose :image do |og_data|
|
||||
og_data.image
|
||||
end
|
||||
|
||||
private_expose :og_data do |id:|
|
||||
url = post_repo.find!(id).url
|
||||
Ogpr.fetch(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,13 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Bookmarks
|
||||
class Show < View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :bookmark do |slug:|
|
||||
Decorators::Bookmarks::Decorator.new(post_repo.fetch!(slug))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,31 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Books
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
private_expose :books do
|
||||
post_repo.books_listing.group_by { |book| book.book_status }
|
||||
end
|
||||
|
||||
expose :read do |books|
|
||||
books["read"].map do |book|
|
||||
Decorators::Books::Decorator.new book
|
||||
end
|
||||
end
|
||||
|
||||
expose :to_read do |books|
|
||||
books["to-read"].map do |book|
|
||||
Decorators::Books::Decorator.new book
|
||||
end
|
||||
end
|
||||
|
||||
expose :reading do |books|
|
||||
books["reading"].map do |book|
|
||||
Decorators::Books::Decorator.new book
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,25 +0,0 @@
|
||||
require "builder"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Feeds
|
||||
class Rss < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :posts do
|
||||
post_repo.for_rss.map do |post|
|
||||
(post.post_type == "bookmark") ?
|
||||
Decorators::Bookmarks::Decorator.new(post) :
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :xml, decorate: false
|
||||
|
||||
def xml
|
||||
Builder::XmlMarkup.new(indent: 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,23 +0,0 @@
|
||||
require "builder"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Feeds
|
||||
class StatusesRss < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :posts do
|
||||
post_repo.statuses_for_rss.map do |post|
|
||||
Decorators::Posts::Decorator.new post
|
||||
end
|
||||
end
|
||||
|
||||
expose :xml, decorate: false, layout: true
|
||||
|
||||
def xml
|
||||
Builder::XmlMarkup.new(indent: 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,8 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module More
|
||||
class Index < View
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,13 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Movies
|
||||
class Index < View
|
||||
include Deps["repos.movie_repo"]
|
||||
|
||||
expose :movies do
|
||||
movie_repo.listing
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,21 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Pages
|
||||
class Show < Adamantium::View
|
||||
include Deps["repos.page_repo", renderer: "renderers.markdown"]
|
||||
|
||||
expose :page_content do |page|
|
||||
renderer.call(content: page.content)
|
||||
end
|
||||
|
||||
expose :page_name do |page|
|
||||
page.name
|
||||
end
|
||||
|
||||
private_expose :page do |slug:|
|
||||
page_repo.fetch!(slug: slug)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,15 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Photos
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :photos do
|
||||
post_repo.photo_listing.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,15 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Places
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :places do
|
||||
post_repo.places_listing.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,18 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Places
|
||||
class MapPage < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
config.layout = "map"
|
||||
|
||||
expose :places do
|
||||
post_repo.places_listing.map do |post|
|
||||
p = Decorators::Posts::Decorator.new(post)
|
||||
[p.lon, p.lat]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,17 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Podcasts
|
||||
class Index < View
|
||||
include Deps["repos.podcast_repo", "repos.podcast_scrobble_repo"]
|
||||
|
||||
expose :podcasts do
|
||||
podcast_repo.listing
|
||||
end
|
||||
|
||||
expose :listens do
|
||||
podcast_scrobble_repo.listing
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,21 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Posts
|
||||
class Archive < View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :year do |year:|
|
||||
year
|
||||
end
|
||||
|
||||
expose :posts do |year:|
|
||||
post_repo.by_year(year: year).map { |post| Decorators::Posts::Decorator.new(post) }
|
||||
end
|
||||
|
||||
expose :post_years do
|
||||
post_repo.post_years.map { |py| py[:year].to_i }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,31 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Posts
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :posts do |post_query|
|
||||
post_query.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
private_expose :post_query do |query|
|
||||
if query
|
||||
post_repo.search(term: query)
|
||||
else
|
||||
post_repo.post_listing
|
||||
end
|
||||
end
|
||||
|
||||
expose :query do |query:|
|
||||
(query == "") ? nil : query
|
||||
end
|
||||
|
||||
expose :post_years do
|
||||
post_repo.post_years.map { |py| py[:year].to_i }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,41 +0,0 @@
|
||||
require "time_math"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Posts
|
||||
class Show < Adamantium::View
|
||||
include Deps["repos.post_repo", "repos.movie_repo"]
|
||||
|
||||
expose :post do |slug:|
|
||||
Decorators::Posts::Decorator.new(post_repo.fetch!(slug))
|
||||
end
|
||||
|
||||
expose :past_posts do |post|
|
||||
start_date = TimeMath.week.floor(post.published_at)
|
||||
end_date = TimeMath.week.ceil(post.published_at)
|
||||
posts = post_repo.from_the_archives(start_date: start_date, end_date: end_date)
|
||||
posts.map { |p| Decorators::Posts::Decorator.new(p) }
|
||||
end
|
||||
|
||||
expose :past_movies do |post|
|
||||
start_date = TimeMath.week.floor(post.published_at)
|
||||
end_date = TimeMath.week.ceil(post.published_at)
|
||||
movies = movie_repo.from_the_archives(start_date: start_date, end_date: end_date)
|
||||
movies.map { |p| Decorators::Movies::Decorator.new(p) }
|
||||
end
|
||||
|
||||
expose :text_posts do |past_posts|
|
||||
past_posts.reject(&:photos?)
|
||||
end
|
||||
|
||||
expose :photo_posts do |past_posts|
|
||||
past_posts.select(&:photos?)
|
||||
end
|
||||
|
||||
expose :trip do |post|
|
||||
post.trips.first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,21 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Posts
|
||||
class TopTracks < Adamantium::View
|
||||
config.layout = false
|
||||
|
||||
expose :name do |track:|
|
||||
track.name
|
||||
end
|
||||
|
||||
expose :artist do |track:|
|
||||
track.artist
|
||||
end
|
||||
|
||||
expose :url do |track:|
|
||||
track.url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,27 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module RecentlyPlayed
|
||||
class Index < Adamantium::View
|
||||
config.layout = false
|
||||
|
||||
include Deps["queries.posts.recently_played"]
|
||||
|
||||
expose :recently_played_music do |recently_played_result|
|
||||
# raise recently_played_result["data"].inspect
|
||||
JSON.parse(recently_played_result)["data"].reject { |a| a["type"] != "albums" }.map do |album|
|
||||
{
|
||||
artist: album["attributes"]["artistName"],
|
||||
name: album["attributes"]["name"],
|
||||
image: album["attributes"]["artwork"]["url"].gsub("{w}", "512").gsub("{h}", "512"),
|
||||
href: album["attributes"]["url"]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private_expose :recently_played_result do
|
||||
recently_played.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,41 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Site
|
||||
class Home < Adamantium::View
|
||||
include Deps["repos.post_repo", renderer: "renderers.markdown"]
|
||||
|
||||
expose :home_content do
|
||||
markdown_content = File.read("app/content/home.md")
|
||||
|
||||
renderer.call(content: markdown_content)
|
||||
end
|
||||
|
||||
expose :week_posts do
|
||||
post_repo.week_posts(limit: 10).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :posts do
|
||||
post_repo.home_post_listing(limit: 5).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :photo_posts do
|
||||
post_repo.photo_listing(limit: 12).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :latest_status do
|
||||
post_repo.latest_status ? Decorators::Posts::Decorator.new(post_repo.latest_status) : nil
|
||||
end
|
||||
|
||||
expose :last_location do
|
||||
post_repo.last_location ? Decorators::Posts::Decorator.new(post_repo.last_location) : nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,15 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Statuses
|
||||
class Index < Adamantium::View
|
||||
include Deps["repos.post_repo"]
|
||||
|
||||
expose :posts do
|
||||
post_repo.statuses_listing.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,20 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Tags
|
||||
class Index < View
|
||||
include Deps["repos.tag_repo"]
|
||||
|
||||
expose :tag_groups do
|
||||
tag_repo
|
||||
.list
|
||||
.group_by { |tag|
|
||||
grouper = tag.label.strip[0].downcase
|
||||
/[a-z]/.match?(grouper) ? grouper : "#"
|
||||
}
|
||||
.sort
|
||||
.map { |group, tags| {group: group, tags: tags.map { |tag| {tag: tag, count: tag.posts.count} }} }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,24 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Tags
|
||||
class Show < Adamantium::View
|
||||
include Deps[
|
||||
"repos.post_tag_repo",
|
||||
"repos.tag_repo"
|
||||
]
|
||||
|
||||
expose :posts do |slug:|
|
||||
post_tag_repo.posts_tagged(tag: slug).map do |post|
|
||||
post.url ?
|
||||
Decorators::Bookmarks::Decorator.new(post) :
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :post_tag do |slug:|
|
||||
tag_repo.fetch!(slug)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,86 +0,0 @@
|
||||
require "time_math"
|
||||
|
||||
module Adamantium
|
||||
module Views
|
||||
module Timemachine
|
||||
class Show < Adamantium::View
|
||||
include Deps[
|
||||
"repos.post_repo",
|
||||
"repos.movie_repo",
|
||||
"repos.podcast_scrobble_repo",
|
||||
"repos.trip_repo"
|
||||
]
|
||||
|
||||
expose :posts do |date|
|
||||
post_repo.posts_for_timemachine(date: date.value).map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :bookmarks do |date|
|
||||
post_repo.bookmarks_for_timemachine(date: date.value).map do |post|
|
||||
Decorators::Bookmarks::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :podcasts do |date|
|
||||
podcast_scrobble_repo.for_timemachine(date: date.value)
|
||||
end
|
||||
|
||||
expose :display_date do |date|
|
||||
date.strftime("%A, %d %B, %Y")
|
||||
end
|
||||
|
||||
expose :next_date do |date|
|
||||
today_to_tomorrow = TimeMath.measure(TimeMath(date.value).advance(:day, +1).call, Time.now)
|
||||
|
||||
unless today_to_tomorrow[:hours] < 0
|
||||
TimeMath.day.advance(date.value, +1)
|
||||
.strftime("%Y/%m/%d")
|
||||
end
|
||||
end
|
||||
|
||||
expose :today do
|
||||
Time.now
|
||||
.strftime("%Y/%m/%d")
|
||||
end
|
||||
|
||||
expose :current_date do |year:, month:, day:|
|
||||
"#{year}/#{month}/#{day}"
|
||||
end
|
||||
|
||||
expose :prev_date do |date|
|
||||
TimeMath.day.advance(date.value, -1)
|
||||
.strftime("%Y/%m/%d")
|
||||
end
|
||||
|
||||
expose :posts_by_month do
|
||||
post_tally = {}
|
||||
posts = post_repo.all_posts
|
||||
|
||||
(DateTime.parse("01-01-#{posts.last.published_at.year}")...DateTime.parse("31-12-#{posts.first.published_at.year}")).each do |date|
|
||||
post_tally[date.year] ||= {}
|
||||
post_tally[date.year][date.strftime("%m")] ||= {}
|
||||
post_tally[date.year][date.strftime("%m")][date.strftime("%d")] = 0
|
||||
end
|
||||
|
||||
post_stats = posts.each_with_object(post_tally) do |post, memo|
|
||||
year = post.published_at.year
|
||||
date = post.published_at
|
||||
memo[year][date.strftime("%m")][date.strftime("%d")] += 1
|
||||
end
|
||||
|
||||
podcast_scrobble_repo.listing.each do |scrobble|
|
||||
post_stats[scrobble.listened_at.year][scrobble.listened_at.strftime("%m")][scrobble.listened_at.strftime("%d")] += 1
|
||||
end
|
||||
|
||||
post_stats.sort_by { |k, _| -k }
|
||||
end
|
||||
|
||||
private_expose :date do |year:, month:, day:|
|
||||
DateTime.parse("#{year}-#{month}-#{day}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,15 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Trips
|
||||
class Index < View
|
||||
include Deps["repos.trip_repo"]
|
||||
|
||||
expose :trip_years do
|
||||
trip_repo
|
||||
.list
|
||||
.group_by { |trip| trip.start_date.year }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,29 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Trips
|
||||
class Show < Adamantium::View
|
||||
include Deps[
|
||||
"repos.trip_repo"
|
||||
]
|
||||
|
||||
expose :posts do |trip|
|
||||
trip.posts.sort { |p, x| p.published_at.to_i <=> x.published_at.to_i }.map do |post|
|
||||
Decorators::Posts::Decorator.new(post)
|
||||
end
|
||||
end
|
||||
|
||||
expose :places do |posts|
|
||||
posts.map do |post|
|
||||
next if post.location.nil?
|
||||
p = Decorators::Posts::Decorator.new(post)
|
||||
[p.lon, p.lat]
|
||||
end.compact
|
||||
end
|
||||
|
||||
expose :trip do |id:|
|
||||
trip_repo.fetch!(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,18 +0,0 @@
|
||||
module Adamantium
|
||||
module Views
|
||||
module Workouts
|
||||
class Index < View
|
||||
include Deps["repos.workout_repo"]
|
||||
|
||||
expose :workouts_by_year do
|
||||
workout_repo
|
||||
.list
|
||||
.group_by { |wo|
|
||||
wo.published_at.year
|
||||
}
|
||||
.sort
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user