-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post Templates #1151
Open
MoshiKoi
wants to merge
28
commits into
codidact:develop
Choose a base branch
from
MoshiKoi:templates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Post Templates #1151
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
9ed3ffe
Implement creating and using post templates
MoshiKoi cfeebc9
Don't show template button if there's no templates
MoshiKoi 7d3c0f2
Remove the debug log
MoshiKoi ec44526
Create a templates category
MoshiKoi fc01f4d
Remove the mod tool since the category exists now
MoshiKoi f058880
Fix a weird positioning bug
MoshiKoi d1d18ac
Only show non-deleted templates
MoshiKoi fa0e842
Add quick link to template post from preview
MoshiKoi 7f3414f
Update app/assets/javascripts/posts.js
MoshiKoi c286056
Fix the tour
MoshiKoi fe600a4
Make implicit conversion explicit
MoshiKoi eef6757
Fix whitespace
MoshiKoi 372242d
Add option to hide categories from the header
MoshiKoi 37b3273
Add template association to Post model
MoshiKoi cc047ac
Fix the foreign key
MoshiKoi 0f1af46
Make template_post_type optional
MoshiKoi e30da3c
Add diff when changing a template's post type
MoshiKoi 5c29075
Merge branch 'develop' into templates
MoshiKoi e24ef2b
Fix markdown editor when the post is not a post
MoshiKoi 52c64c8
Fix template_post_type in PostHistory
MoshiKoi ada2b8c
Rubocop
MoshiKoi b4c3dff
Insert into rather than replace post content
MoshiKoi 24e0a58
Merge branch 'develop' into templates
Oaphi 2fddcc5
Use -1 instead of null to hide categories
MoshiKoi 56c239a
Fix disappearance of tools on non-posts
MoshiKoi a5cadcd
Merge branch 'develop' into templates
Oaphi 3c7f82c
Merge branch 'develop' into templates
MoshiKoi 658f2e1
Close the modal after choosing the template
MoshiKoi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,6 @@ hr { | |
} | ||
|
||
.modal { | ||
position: fixed !important; | ||
z-index: 8998; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class PostTemplate < Post | ||
def self.post_type_id | ||
PostType.mapping['PostTemplate'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddTemplatePostTypeToPosts < ActiveRecord::Migration[7.0] | ||
def change | ||
add_reference :posts, :template_post_type, foreign_key: { to_table: :post_types } | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20230813161623_add_before_and_after_template_post_type_to_post_histories.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddBeforeAndAfterTemplatePostTypeToPostHistories < ActiveRecord::Migration[7.0] | ||
def change | ||
add_reference :post_histories, :before_template_post_type, foreign_key: { to_table: :post_types } | ||
add_reference :post_histories, :after_template_post_type, foreign_key: { to_table: :post_types } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is intentional that templates are overwriting the selection, or if nothing is selected, just append at the cursor location?
I'm more used to implementations where templates replace the current content. What was the idea behind the different approach? To allow defining sort of common elements as templates?
I can see it happening that a user tries to select text and then accidentally clicks on a template, after which their selection is gone (no confirmation). Not sure if that weighs up against the extra effort of having to confirm something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Monica's comment here: #1151 (comment), but also a confirmation would also be nice to have if they still have selected text that might be overridden (undo functionality is broken on all Markdown tools (#1152), so there's no going back).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah in my tests if you select text it does override (which is luckily consistent with what the javascript method is named after). The question is how complex we would want to make it.