1
0
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:
Daniel Barber 2022-08-16 19:57:12 -05:00
parent 8241136e39
commit 617bd2c101
5 changed files with 16 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -21,7 +21,8 @@ module Micropub
get "/micropub/main" do
json data: {
posts: github.posts
posts: github.posts,
photos: github.photos,
}
end

View File

@ -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)

View File

@ -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