-
Notifications
You must be signed in to change notification settings - Fork 685
Use House for MD comments #144
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
Conversation
|
|
||
| private | ||
| def set_slug | ||
| self.slug = "#{slug_basename}-#{SecureRandom.alphanumeric(6)}.#{slug_extension}" |
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.
Perhaps too easy to guess? Would still require a ton of tries, which we would presumably catch and block. But still.
I think the only benefit to not have this be a long thing with a ton of entropy is that we'll be displaying this after attaching something in the markdown. It's nice to see a url that's easy to grok.
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. That's about 56 billion possibilities per name, so not tiny, but still.
We could always make it a little longer but use dashed groups to make it more readable? 3 groups of 4 would give you names more like charlie-bk8e-pK79-MA25 which doesn't look too bad?
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.
Oh you're right! I should've done the math there. I thought the number was way smaller. I think my brain forgot these are alphanumeric 😂.
The dashed groups do look nice. But thinking more about it, if someone is able to execute ~50 billion guesses without us stopping them then we might have bigger issues at hand. Probably good to leave as-is then.
* main: Adjust position of settings buttons Actually, no need for a max-size, just let it grow Improve comment form design Same style as combobox pop-ups Ensure bubbles are clickable anyplace in windshield Deal with truncation in the list layout, too Ensure tags don't affect the bubble shape or spill out of the container Style pop-up UI for selecting assignments and tags Adjust position now that bubbles won't be so vertical Fix that bubbles could collapse in some situations dep: bump rexml to address dependabot alert dep: bump rails to edge
* main: Bump rails from `91d4563` to `5520bd8` dep: bundle update everything except rails dep: update sqlite3 gem to v2.4.1
* main: (23 commits) Improve the flow for editing bubble titles Use path helpers in tests Revising access shouldn't do a replace turbo-action Split into new tests Update this test, too Adjust tests to match new behavior Reapply "Destroy equivalent filters upon resource removal" Revert "Destroy equivalent filters upon resource removal" Destroy equivalent filters upon resource removal Don't autocomplete Rework boosts form so you can enter any integer Pull out access_menu_tag Punt on removing filters for inaccessible buckets Can't see bubbles in buckets you've lost access to Users can remove themselves from buckets Fix redirect assertion Fix redirect assertion Submit form when toggling all-access + caching Unnecessary parens Can't revoke access to all-access bucket ...
* main: Update test Wire up comment deletion Whitespace Wire up editing comments Open the title field for editing after creating a new bubble
|
@kevinmcconnell ran out of time today to rip out the custom renderer. But using Redcarpet would just be a matter of changing the config. Everything else would stay the same. CI is failing because it can't pull the gem from the private House repo. |
kevinmcconnell
left a comment
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.
This looks good so far!
I think, as discussed previously, it's probably still worth splitting the House rendering work to its own branch while you explore that. Unless you're confident that it's definitely the right approach. But I think what I'd be trying to answer there is: what limitations are there in a hand-built Markdown renderer, compared to something like Redcarpet?
My hunch is that there are a bunch of edge cases to consider with Markdown rendering, especially with things like formatting that's inside other formatting, and so on. House is able to render some reasonable subset of Markdown in order to provide format previews while you're editing. But it's OK if it doesn't support everything. You can still put in any Markdown text you want, and even if it's not something House knows how to deal with it'll still work -- it just might not get previewed. But, once you actually save some markdown content, you'd want that to render accurately.
But I haven't looked closely at this, so maybe that's a bad assumption on my part! I'd be interested to hear what you find out about it.
| belongs_to :creator, class_name: "User", default: -> { Current.user } | ||
|
|
||
| searchable_by :body, using: :comments_search_index | ||
| searchable_by :body_plain_text, using: :comments_search_index, as: :body |
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.
We could also make the FTS field match the name of the method we're indexing, and then wouldn't need the as parameter.
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.
Ah yes, as in renaming the db column for the search table?
I considered that but I thought _as_plain_text was a sort of implementation detail. With as: we can keep the semantic meaning in the search table that we're searching the comment's body, regardless of how we serialized it for indexing.
We can also swap out the method without involving a migration. Although I don't expect that to be common.
| def searchable_by(field, using:) | ||
| define_method :search_field do field; end | ||
| def searchable_by(field, using:, as: field) | ||
| define_method :search_value do send(field); end |
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.
Good idea to define this search_value method! 👏
| %w[ rails_ext ].each do |extensions_dir| | ||
| Dir["#{Rails.root}/lib/#{extensions_dir}/*"].each { |path| require "#{extensions_dir}/#{File.basename(path)}" } | ||
| end | ||
| Dir["#{Rails.root}/lib/rails_ext/*"].each { |path| require "rails_ext/#{File.basename(path)}" } |
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'm just curious -- is this changing because we didn't have any extensions for other libraries yet? The previous was just in there because it was brought in from another project?
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.
Yes! I brought it over from some other project but in re-evaluating, I'm not expecting to extend anything else. So just a very minor nit.
We can revert to using an array if we ever extend something other than Rails.
|
|
||
| private | ||
| def set_slug | ||
| self.slug = "#{slug_basename}-#{SecureRandom.alphanumeric(6)}.#{slug_extension}" |
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. That's about 56 billion possibilities per name, so not tiny, but still.
We could always make it a little longer but use dashed groups to make it more readable? 3 groups of 4 would give you names more like charlie-bk8e-pK79-MA25 which doesn't look too bad?
| module ChoiceSentenceArrayConversion | ||
| def to_choice_sentence | ||
| to_sentence two_words_connector: " or ", last_word_connector: ", or " |
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.
Is this an unrelated change?
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.
Sort of – this dir was previously autoloaded. Which required the constant name to match the file path.
After adding many more extensions to the dir (for ActionText) it made more sense to not autoload. So changing that setting in application.rb triggered this diff tangentially.
|
Thanks for the review @kevinmcconnell! Right! I'll replace the custom renderer with redcarpet today and merge. The tests will pass then, and the diff will be pretty minor (just a config change and minor syntax changes in the MardownRenderer). As for the benefit of having a custom renderer – I think it'd be a library benefit more than a product one. It allows us to provide a zero-config default answer for rendering I hear ya about the edge cases. I was able to get pretty far with a day's worth of effort so I'm optimistic it might not be super hard. But I might be wrong of course! And the edge cases might very well stop that project in its tracks. They haven't yet, though! |
* main: Add hotwire-spark Fix for Safari which doesn't support `field-sizing: content` Add button and action to delete a bubble Indicate draggable element Stub draggable collection size divider Make close and trash more distinct
Deviations from other House implementations:
#{name}_htmland#{name}_plain_textslug_url's default params#render), and refactored our bespokeMarkdownRendererclass