Skip to content
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

85% of URL #564

Merged
merged 6 commits into from
Oct 14, 2024
Merged

85% of URL #564

merged 6 commits into from
Oct 14, 2024

Conversation

Schwad
Copy link
Collaborator

@Schwad Schwad commented Oct 9, 2024

Description

I'm SO CLOSE to getting all the way there. But there is a fair enough chunk of this to ship the current utility.

You define URLs atop the file. You can then "visit" them (this is patched on top of existing page functionality). The REALLY neat thing is you can pass in parameters like integers and strings to make the page render DIFFERENT things. (Think like a controller!). This was part of original shoes urls. Very fun. Very exciting.

Also I stumbled upon an implicit shoes convention and implemented it. If all of your app code is boxed into methods for your urls, it defaults to index if defined. So I added in support for rendering the index url if defined. This only applies to url

Note one

My autoformatting editor makes this harder to review than I'd like. Instead of going back and undoing all the autoformatters this time... I'll turn my autoformatter off for future PRs. I'm sorry.

Note two

@noahgibbs maybe I can nerd snipe you on this one. (No presh obvs, you might find it interesting)

If you look at _why-stories.rb, on line 18, you can see what we're missing. Essentially we need

para link('foo', click: '/my/url').

But my efforts were not able to yield a win yet. Because click is a javascript and web concern as well, so, trying to update it to 'visit' a valid url, we get failures saying that it "could not open url". And I struggled to get outputs even with debug on run. We currently support going to an "actual" external URL, but I'm okay for that feature to die. It was never shoes-spec and I don't really want this to navigate to external websites anyway.

I think it could be very tricky! But we also haven't touched link in a year and a half I think so...

BONUS:

We also don't currently support

class Thing < Shoes
  #some shoes stuff
end

Shoes.app :width => 640, :height => 700,
  :title => "Incidents, a Book"

But I might file an issue.

Image(if needed, helps for a faster review)

Screenshot 2024-10-09 at 15 21 26
Screenshot 2024-10-09 at 15 21 32

Checklist

  • Run tests locally

@Schwad Schwad requested a review from noahgibbs October 9, 2024 14:56
@Schwad Schwad self-assigned this Oct 9, 2024
private

def render_index_if_defined_on_first_boot
return if $first_boot_finished
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a global here is too gnarly and an ivar will do

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, ivar would be plenty.

return if @do_shutdown

with_slot(@document_root) do
@content_container = flow(width: 1.0, height: 1.0)
with_slot(@content_container, &@app_code_body)
end

render_index_if_defined_on_first_boot
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a few homes for this, which seemed to break and not make sense. Hopefully this is the best home

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me on first blush.

@noahgibbs
Copy link
Collaborator

Will review this soon - got a friend visiting and we're off to get him a variety of whisky :-)

begin
# I'm not finding a global_variable_get or similar...
global_value = eval s
drawables &= [global_value]
rescue
#raise Shoes::Errors::InvalidAttributeValueError, "Error getting global variable: #{spec.inspect}"
rescue StandardError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rescuing StandardError is the default. Any reason to mention it explicitly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was an autoformatter rule for rescuing without specifying what we're rescuing. but if you don't say anything it reverts explicitly to the default. i have no opinion on this so i've reverted. and my autoformatter is now off

@Schwad Schwad merged commit 57fcf2f into main Oct 14, 2024
@@ -181,34 +185,33 @@ def current_draw_context
# want to (and/or can't) take control of the event loop.
def run
if @do_shutdown
$stderr.puts "Destroy has already been signaled, but we just called Shoes::App.run!"
warn 'Destroy has already been signaled, but we just called Shoes::App.run!'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I wonder if we ever shut down the logfile stuff. Because warn won't appear if logfile stuff isn't currently working. But this should only get called after the logs are initialised, so definitely no startup problem.

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.

2 participants