Skip to content

Conversation

@josefarias
Copy link

@josefarias josefarias commented Nov 28, 2024

composing rendered
CleanShot 2024-11-29 at 18 44 13 CleanShot 2024-11-29 at 18 45 38

Deviations from other House implementations:

  • Uploads are associated to the account, instead of the markdown record
    • Fizzy's markdown records don't exist as you're composing them (e.g. for new comments), contrary to Writebook
  • Added a plaintext renderer (for searching content)
    • Added convenience methods for #{name}_html and #{name}_plain_text
  • Markdown is sanitized, since it's no longer necessarily trusted
  • Removed embeds for now
    • Wasn't causing any issues, we just don't need it (yet)
  • Fixed a bug with slug_url's default params
  • Some refactoring around specifying and calling a markdown renderer (to make it agnostic to the renderer's interface — previously it had to respond to #render), and refactored our bespoke MarkdownRenderer class


private
def set_slug
self.slug = "#{slug_basename}-#{SecureRandom.alphanumeric(6)}.#{slug_extension}"
Copy link
Author

@josefarias josefarias Nov 30, 2024

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.

Copy link
Collaborator

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?

Copy link
Author

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.

Jose Farias added 11 commits December 9, 2024 10:39
* 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
@josefarias
Copy link
Author

@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.

Copy link
Collaborator

@kevinmcconnell kevinmcconnell left a 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
Copy link
Collaborator

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.

Copy link
Author

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
Copy link
Collaborator

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)}" }
Copy link
Collaborator

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?

Copy link
Author

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}"
Copy link
Collaborator

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?

Comment on lines +1 to +3
module ChoiceSentenceArrayConversion
def to_choice_sentence
to_sentence two_words_connector: " or ", last_word_connector: ", or "
Copy link
Collaborator

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?

Copy link
Author

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.

@josefarias
Copy link
Author

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 ActionText::Markdown (more here).

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!

Jose Farias added 3 commits December 18, 2024 16:27
* 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
@josefarias josefarias merged commit bd28ea8 into main Dec 18, 2024
4 checks passed
@josefarias josefarias deleted the house branch December 18, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants