#19 ひとまづ表示のみ

This commit is contained in:
2025-06-08 05:51:03 +09:00
parent 5a3f79e7c7
commit 39dce3a39f
11 changed files with 1294 additions and 145 deletions
@@ -1,16 +1,24 @@
class WikiPagesController < ApplicationController
def index
end
def show
end
def create
p params
wiki_page = WikiPage.find_by(title: params[:title])
if wiki_page
render plain: wiki_page.markdown
else
head :not_found
end
end
def update
end
return head :unauthorized unless current_user
def destroy
title = params[:title]
wiki_page = WikiPage.find_by(title: title)
unless wiki_page
wiki_page = WikiPage.new(title: title, created_user: current_user, updated_user: current_user)
end
wiki_page.markdown = params[:markdown]
wiki_page.save!
head :ok
end
end
@@ -1,31 +0,0 @@
require 'net/http'
require 'uri'
class WikiProxyController < ApplicationController
def edit
tag = params[:tag]
uri = "http://localhost:4567/gollum/edit/#{ URI.encode_www_form_component(tag) }"
begin
res = fetch_with_redirect(uri)
render html: res.body.html_safe, content_type: res.content_type
rescue => e
render plain: "Wiki システムとの通信に失敗しました:#{ e.message }", status: 502
end
end
private
def fetch_with_redirect uri_str, limit = 5
raise 'Too many redirects' if limit == 0
uri = URI.parse(uri_str)
res = Net::HTTP.get_response(uri)
if res.is_a? Net::HTTPRedirection
location = res['location']
fetch_with_redirect(location, limit - 1)
else
res
end
end
end