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"]
|
USER = ENV["GITHUB_USER"]
|
||||||
REPO = ENV["GITHUB_REPO"]
|
REPO = ENV["GITHUB_REPO"]
|
||||||
|
|
||||||
CONTENT_PATH = "/content/blog"
|
BLOG_PATH = "/content/blog"
|
||||||
|
PHOTOS_PATH = "/content/photos"
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@github = ::Github.new(oauth_token: TOKEN)
|
@github = ::Github.new(oauth_token: TOKEN)
|
||||||
@ -30,7 +31,13 @@ module Micropub
|
|||||||
|
|
||||||
def posts
|
def posts
|
||||||
@_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)
|
map(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ module Micropub
|
|||||||
class Post
|
class Post
|
||||||
attr_accessor :params
|
attr_accessor :params
|
||||||
|
|
||||||
|
BASE_PATH="/blog"
|
||||||
|
|
||||||
def initialize(params = {})
|
def initialize(params = {})
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
@ -23,7 +25,7 @@ module Micropub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
"/blog/#{published.strftime("%Y/%m/%d")}/#{id}"
|
"#{BASE_PATH}/#{published.strftime("%Y/%m/%d")}/#{id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncated_content
|
def truncated_content
|
||||||
|
|||||||
@ -21,7 +21,8 @@ module Micropub
|
|||||||
|
|
||||||
get "/micropub/main" do
|
get "/micropub/main" do
|
||||||
json data: {
|
json data: {
|
||||||
posts: github.posts
|
posts: github.posts,
|
||||||
|
photos: github.photos,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ describe Micropub::Github do
|
|||||||
|
|
||||||
Hello, World!
|
Hello, World!
|
||||||
CONTENT
|
CONTENT
|
||||||
:branch => "master",
|
:branch => "main",
|
||||||
}).returns(true)
|
}).returns(true)
|
||||||
repos = mock("repos")
|
repos = mock("repos")
|
||||||
repos.stubs(:contents).returns(contents)
|
repos.stubs(:contents).returns(contents)
|
||||||
|
|||||||
@ -9,7 +9,6 @@ class HelloWorldTest < MiniTest::Test
|
|||||||
|
|
||||||
def test_hello_world
|
def test_hello_world
|
||||||
get '/'
|
get '/'
|
||||||
assert last_response.ok?
|
assert last_response.redirect?
|
||||||
assert_equal "Hello, World!", last_response.body
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user