Browse Source

#188

feature/188
みてるぞ 5 days ago
parent
commit
1f44b17846
2 changed files with 11 additions and 6 deletions
  1. +7
    -2
      backend/app/controllers/wiki_pages_controller.rb
  2. +4
    -4
      frontend/src/pages/wiki/WikiDiffPage.tsx

+ 7
- 2
backend/app/controllers/wiki_pages_controller.rb View File

@@ -49,7 +49,7 @@ class WikiPagesController < ApplicationController
case change.action case change.action
when ?= when ?=
{ type: 'context', content: change.old_element } { type: 'context', content: change.old_element }
when ?|
when ?!
[{ type: 'removed', content: change.old_element }, [{ type: 'removed', content: change.old_element },
{ type: 'added', content: change.new_element }] { type: 'added', content: change.new_element }]
when ?+ when ?+
@@ -98,13 +98,18 @@ class WikiPagesController < ApplicationController
return head :unprocessable_entity if title.blank? || body.blank? return head :unprocessable_entity if title.blank? || body.blank?


page = WikiPage.find(params[:id]) page = WikiPage.find(params[:id])
base_revision_id = page.current_revision.id


if params[:title].present? && params[:title].strip != page.title if params[:title].present? && params[:title].strip != page.title
return head :unprocessable_entity return head :unprocessable_entity
end end


message = params[:message].presence message = params[:message].presence
Wiki::Commit.content!(page:, body:, created_user: current_user, message:)
Wiki::Commit.content!(page:,
body:,
created_user: current_user,
message:,
base_revision_id:)


head :ok head :ok
end end


+ 4
- 4
frontend/src/pages/wiki/WikiDiffPage.tsx View File

@@ -40,10 +40,10 @@ export default () => {
{diff {diff
? ( ? (
diff.diff.map (d => ( diff.diff.map (d => (
<span className={cn (d.type === 'added' && 'bg-green-200 dark:bg-green-800',
d.type === 'removed' && 'bg-red-200 dark:bg-red-800')}>
{d.content == '\n' ? <br/> : d.content}
</span>)))
<p className={cn (d.type === 'added' && 'bg-green-200 dark:bg-green-800',
d.type === 'removed' && 'bg-red-200 dark:bg-red-800')}>
{d.content}
</p>)))
: 'Loading...'} : 'Loading...'}
</div> </div>
</MainArea>) </MainArea>)


Loading…
Cancel
Save