mirror of
https://github.com/danbee/micropub.git
synced 2025-03-04 08:59:13 +00:00
Add photos to get and fix tests
This commit is contained in:
parent
8241136e39
commit
617bd2c101
@ -6,7 +6,8 @@ module Micropub
|
||||
USER = ENV["GITHUB_USER"]
|
||||
REPO = ENV["GITHUB_REPO"]
|
||||
|
||||
CONTENT_PATH = "/content/blog"
|
||||
BLOG_PATH = "/content/blog"
|
||||
PHOTOS_PATH = "/content/photos"
|
||||
|
||||
def initialize
|
||||
@github = ::Github.new(oauth_token: TOKEN)
|
||||
@ -30,7 +31,13 @@ module Micropub
|
||||
|
||||
def posts
|
||||
@_posts ||=
|
||||
github.repos.contents.get(USER, REPO, CONTENT_PATH).
|
||||
github.repos.contents.get(USER, REPO, BLOG_PATH).
|
||||
map(&:name)
|
||||
end
|
||||
|
||||
def photos
|
||||
@_photos ||=
|
||||
github.repos.contents.get(USER, REPO, PHOTOS_PATH).
|
||||
map(&:name)
|
||||
end
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@ module Micropub
|
||||
class Post
|
||||
attr_accessor :params
|
||||
|
||||
BASE_PATH="/blog"
|
||||
|
||||
def initialize(params = {})
|
||||
@params = params
|
||||
end
|
||||
@ -23,7 +25,7 @@ module Micropub
|
||||
end
|
||||
|
||||
def path
|
||||
"/blog/#{published.strftime("%Y/%m/%d")}/#{id}"
|
||||
"#{BASE_PATH}/#{published.strftime("%Y/%m/%d")}/#{id}"
|
||||
end
|
||||
|
||||
def truncated_content
|
||||
|
||||
@ -21,7 +21,8 @@ module Micropub
|
||||
|
||||
get "/micropub/main" do
|
||||
json data: {
|
||||
posts: github.posts
|
||||
posts: github.posts,
|
||||
photos: github.photos,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ describe Micropub::Github do
|
||||
|
||||
Hello, World!
|
||||
CONTENT
|
||||
:branch => "master",
|
||||
:branch => "main",
|
||||
}).returns(true)
|
||||
repos = mock("repos")
|
||||
repos.stubs(:contents).returns(contents)
|
||||
|
||||
@ -9,7 +9,6 @@ class HelloWorldTest < MiniTest::Test
|
||||
|
||||
def test_hello_world
|
||||
get '/'
|
||||
assert last_response.ok?
|
||||
assert_equal "Hello, World!", last_response.body
|
||||
assert last_response.redirect?
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user