#45 API ぼちぼち

This commit is contained in:
2025-06-18 06:20:51 +09:00
parent ceeefa9b7c
commit c6f7e8a696
5 changed files with 30 additions and 1 deletions
@@ -49,4 +49,22 @@ class WikiPagesController < ApplicationController
render json: q.limit(20)
end
def changes
id = params[:id]
log = id.present? ? wiki.page("#{ id }.md").versions : wiki.repo.log('main', nil, max_count: 50)
render json: log.map { |commit|
{ sha: commit.id,
author: commit.author.name,
message: commit.message,
timestamp: commit.authored_date } }
end
private
WIKI_PATH = Rails.root.join('wiki').to_s
def wiki
@wiki ||= Gollum::Wiki.new(WIKI_PATH)
end
end