szkl has quit [Quit: Connection closed for inactivity]
Artea has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
CrazyEddy has quit [Remote host closed the connection]
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
<ih8u>
fuck web dev
Paris has quit [Quit: quit]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
FullMetalStacket has joined #ruby
<FullMetalStacket>
Heyho all! Does anyone here use Rubymine IDE and can tell me if it is worth it?
jenrzzz has quit [Ping timeout: 256 seconds]
FullMetalStacker has joined #ruby
polishdub has joined #ruby
FullMetalStacket has quit [Quit: Konversation terminated!]
<adam12>
ih8u: Yes, that's me.
FullMetalStacker has quit [Read error: Connection reset by peer]
<adam12>
ih8u: r.referrer is from Rack::Request. r is a Roda::RodaRequest object, which inherits from Rack::Request.
<adam12>
ih8u: Roda has two different ways of doing CSRF. One is the typical meta-tag, works for any request style, which is similar to Rails and other frameworks. Then it has `route_csrf`, which is specific per route. This can conflict with Unpoly, depending on what you're doing, because Unpoly needs to be able to submit with a CSRF token.
<adam12>
ih8u: In my example I gave you with a form, I didn't know you were using roda. If you are, make sure you are rendering with the `csrf_tag` if you're using a CSRF plugin for Roda. If you show some code, I can maybe guide you a bit better.
<adam12>
I don't know why Unpoly wouldn't work without a page reset, but maybe it's not booting correctly. You can `up.log.enable()` in your browser window and then see if it shows anything. If you paste the log to a Gist, I can look at it.
jenrzzz has joined #ruby
<adam12>
You can use route_csrf with Unpoly, but you need a small snippet of JS to gather the CSRF token from somewhere, if it doesn't already have it. I like to make my applications gracefully enhance, which means that every form has a CSRF tag so it works without Unpoly. So if it works without Unpoly, I add the up- attributes and everything continues to
<adam12>
work.
<ih8u>
i was just in the process of discovering csrf being the root of my issue here
<ih8u>
but i still can't figure out how to make it work
<ih8u>
i embed csrf_tag, but i still get the same error
<adam12>
Which roda plugin are you using for csrf.
jenrzzz has quit [Ping timeout: 264 seconds]
<ih8u>
route_csrf
<ih8u>
i'm using the form from your example
<adam12>
And what does the csrf_tag method call look like?
jenrzzz has joined #ruby
<adam12>
It needs a path and a method. csrf_tag("/the-path-to-send-to", "POST") or similar.
<ih8u>
but inserted "post" and "test" for method and action, respectively
<ih8u>
okay, thank you, that seems to be the crucial bit of information i was missing
<ih8u>
there is so much assumed knowledge
<adam12>
Yeah :|
<ih8u>
now to figure out unpoly
<adam12>
I've read the Roda source a dozen times by now, so I know most of it by hand. I've got a few larger applications running Roda+Unpoly.
jenrzzz has quit [Ping timeout: 245 seconds]
<ih8u>
it's nice to have people like you around
<adam12>
:)
<adam12>
For Unpoly assistance, definitely use the Github discussions. I'm active on there as well as Henning, the creator.
<ih8u>
i can sit here and bash my head against the wall for hours without realizing i need to pass a path to get a valid csrf token
<adam12>
I'm surprised it didn't error, tbh.
<adam12>
I thought it forced the arguments (at least the first one).
<adam12>
I think it implies POST.
<ih8u>
it does, and apparently implies nil for the path
<adam12>
Ah, that's a shame.
<adam12>
I'm sure there is a reason, but that UX is unfortunate.
jenrzzz has joined #ruby
<ih8u>
so the good news is that i'm successfully running server-side code on a button click
<adam12>
Nice.
<ih8u>
and i can see the changes by calling `r.redirect r.referrer`
<ih8u>
but that obviously reloads the entire page
<adam12>
What `up-` attributes are you using
<ih8u>
i don't understand how reloading only some specific subset of elements works
<ih8u>
up-target=".likes"
<adam12>
Well, you provide an `up-target` with an identifier. Unpoly looks for that identifer in the response, and then replaces it in the current body.
<ih8u>
on the form
<ih8u>
the `<div class=".likes">` inside
<adam12>
Inside your browser console, you see Unpoly booted?
<adam12>
(shows a banner by default)
<ih8u>
i've got logging enabled for it
<ih8u>
and i see the logger telling me stuff
jenrzzz has quit [Ping timeout: 260 seconds]
<ih8u>
but i don't know if that's the same thing as having it "booted"
<adam12>
Yeah.
<adam12>
Paste the log output to a gist.
jenrzzz has joined #ruby
<ih8u>
`up.render() Could not match primary target ".likes". Updating a fallback target "main".`
<adam12>
Oh. I see.
<adam12>
Maybe.
<adam12>
you need `likes` inside the div class, but `.likes` inside up-target.
<ih8u>
i mean, why a . in one, and none in the other?
<adam12>
The . notation is used for selecting classes. You can use # to select id's, and a bunch of other ones.
<ih8u>
well, i know that from css
<adam12>
Unpoly follows what jQuery used to do (it was written to use jQuery in v1). And jQuery always used the CSS-like selectors.
<ih8u>
but why do it that way in an html tag?
<ih8u>
oh
<ih8u>
interesting
<adam12>
It's similar to document.queryElement, which works the same way now. Something adopted from the early 2000's and has lived on.
<adam12>
err, document.querySelector
<ih8u>
i hate web dev
<adam12>
LOL. Me too, but tbh, Unpoly and newer CSS updates made it palatable to me.
<ih8u>
even when i find something that seems to make it almost tolerable
<ih8u>
something always comes up to remind me why i hate it so much
<ih8u>
why unpoly vs turbo?
<adam12>
Well, when I picked up Unpoly, Turbo wasn't as good as it is now.
<adam12>
I've been doing Unpoly since ~ 2016?
<adam12>
Only fairly recently did Turbo get turbo frames, turbo streams, etc.
<adam12>
It's also JS-centric. You _need_ JS enabled. Which is probably fine in 2024 but back in 2016, we were still trying to progressively enhance.
jenrzzz has quit [Ping timeout: 260 seconds]
<adam12>
I think they are both fine choices now. There's also HTMX.
<adam12>
I used HTMX before Unpoly, but it was called IntercoolerJS at the time. It worked well also, but Unpoly ships with a ton more builtins.
jenrzzz has joined #ruby
<adam12>
ie. modals are easy with Unpoly. `up-target=".some-element" up-layer="new modal"`.
<adam12>
Automatic polling for some message counter? `<div class="messages" up-poll="5_000">message count</div>`.
<ih8u>
i admit, what i've done here was pretty smooth
<ih8u>
if csrf hadn't fucked me up for so long, it would have been fairly painless
<ih8u>
i probably would have tried the "likes not .likes" thing before long
<adam12>
Yeah :( you were already super close.
<adam12>
This is what I came across back in the day for Unpoly, since I was doing Angular/Knockout/etc. Totally converted me. https://triskweline.de/unpoly-rugb/#/
<ih8u>
what's that about automatic polling?
<adam12>
It's slightly out of date now, since Unpoly 2 supports infinite layers. You can branch off from a certain step (ie. creating a new order) to create a new customer record, and then return to the pre-existing new order page and select the new customer you just created from the dropdown.
jenrzzz has quit [Ping timeout: 245 seconds]
<adam12>
Well, if you had some sort of Unread Message indicator in a web app, you might look at doing websockets or SSE. But both of these can require certain architecture choices. The simplest solution might just be to poll every 5 seconds, and have Unpoly update the indicator with the message count and if any new messages came in.
<ih8u>
i see
<ih8u>
neat
jenrzzz has joined #ruby
<ih8u>
is there a more elegant way to do `r.redirect r.referrer`?
<ih8u>
i mean, i guess it works (as intended?), but something about it feels dirty
<adam12>
Not in Roda, that I know of (in Sinatra, there's `redirect back` but it clobbers the `back` method)
<adam12>
Could just leave off r.referrer maybe
<ih8u>
that doesn't seem to work
<adam12>
I thought it might default to `r.referrer`.
<ih8u>
it seems to default to the get equivalent, at least for post requests
<ih8u>
that's handy in its own way
<ih8u>
should i be using post or fetch?
<adam12>
For which?
<ih8u>
for which what? lol
<adam12>
I don't get the post vs fetch
<ih8u>
for the submit form
<adam12>
like `method="post"`? I still don't follow.
<ih8u>
you have really lifted a huge weight off of my shoulders, man
<adam12>
Glad to hear it.
<ih8u>
thank you for your patience
<adam12>
No worries.
<ih8u>
and time
<ih8u>
and energy
<ih8u>
i'm going to keep playing around with this
<ih8u>
but now that i have my foot in the door, i should be (mostly) okay
<adam12>
Not much to it. For Unpoly at least, try to get it working _without_ Unpoly first.
<adam12>
So for your likes button, the form would submit per usual but just be a regular request->reply.
<adam12>
Then add Unpoly, since it builds on top of it.
<ih8u>
i think i did that inadvertently
<adam12>
I just find it simpler for people to understand. They are trying to get Unpoly to work, but Unpoly is confused because the regular form wouldn't work anyways, and the browser is confused.
<adam12>
but other than that, not much to it.
<adam12>
And for Roda, definitely peek at source. It's all nicely contained inside mostly single files for plugins.
<ih8u>
i appreciate the advice
<ih8u>
thank you very kindly
<adam12>
Cheers.
jenrzzz has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
<adam12>
Oh, for your IDE question. VSCode for free, RubyMine if you're OK with a license. RubyMine is definitely better than VSCode if you're willing to pay. I use Neovim and I think some others in here use Emacs.
<ih8u>
i take a hardline stance against microsoft, so won't touch vscode
jenrzzz has quit [Ping timeout: 256 seconds]
<ih8u>
i've heard good things about rubymine (and all of jetbrains's stuff; i quite like intellij) but haven't justified putting up the scratch for it
<ih8u>
maybe i should
<ih8u>
i'm too soft for terminal text editors
<havenwood>
VSCode is pretty nice and works well on non-Windows OSes.
<havenwood>
adam12: I use neovim too.
<havenwood>
VSCode from time to time.
<adam12>
I was using VSCode with the Vim plugin, then VSCode with Neovim, but I am allergic to latency and I can detect it even if faint.
<adam12>
I missed some of the configuration pieces that Neovim offers, tho that said, I spent like 20 hours last few weeks modifying Neovim.. so.
<adam12>
I don't like spending _that_ much time customizing.
<ih8u>
i don't understand neovim at all
<havenwood>
Seems nice, but not sure I'm ready to take the plunge.
<ih8u>
like, i am completely mystified by it
<adam12>
I am not sure how I could get the keybindings out of my head. I've been using them for like 30 years :(
<adam12>
Same with kakoune.
<havenwood>
ih8u: Maybe give Helix a try since you're not already muscle-memory bound to Vim.
<adam12>
It makes more sense, how you do the selection THEN the operation, but my fingers just don't like co-operating.
A_Dragon has joined #ruby
<ih8u>
i like that they distribute an official appimage
<adam12>
I was using VSCode when I was briefly on Windows.
A_Dragon is now known as Festive_Dragon
<adam12>
But the best thing I ever did for my Neovim experience is drop tmux. Everybody raves about it, but all it did for me is get in my way. I still use tmux/scren on servers, but tmux + neovim means a magic incantation to get the 256 colours to work, the escape key to be faster, no latency, etc etc etc.
<adam12>
Rather just use a better terminal emulator like Wezzterm.
Festive_Derg has quit [Killed (Festive_Dragon (BEGONE GHOST OF MY PAST))]
Festive_Dragon is now known as Festive_Derg
<ih8u>
oh, helix is tui
<ih8u>
what's wrong with a mouse?
<adam12>
ih8u: Slow :P
<ih8u>
not 100% of the time
nkm has quit [Ping timeout: 250 seconds]
<adam12>
ih8u: Sure, but definitely noticeable at least for me, when I work/pair with teammates.
<ih8u>
i also don't like that all my shortcuts change
<adam12>
What editor are you using currently?
<ih8u>
kate
<adam12>
Have you tried Geany at all?
<adam12>
If you're using Kate, I guess you're running KDE?
jenrzzz has quit [Ping timeout: 264 seconds]
<adam12>
I am not sure how Geany would look inside a KDE env.
<ih8u>
oh, man, i haven't tried geany in years
<ih8u>
like a decade
<ih8u>
how did i forget about it?
<ih8u>
i'm in gnome, actually (yuck)
<ih8u>
pop os makes it mostly tolerable
<adam12>
Yeah, I used PopOS for a bit.
jenrzzz has joined #ruby
<ih8u>
woof, that's ugly
<ih8u>
nostalgic, but ugly
<adam12>
Geany? I hadn't used it in years either.
<ih8u>
yeah, geany
<ih8u>
i've also recently been made aware of textadept
<ih8u>
though i don't have an opinion on it
rvalue has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
asc has quit [Ping timeout: 268 seconds]
rvalue has joined #ruby
<adam12>
TIL: debug/prelude
<adam12>
Tho I wonder if it would be better if the command it installs wasn't absolute to a path with a Ruby version in it.
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
rhe has quit [Quit: Ping timeout (120 seconds)]
rhe has joined #ruby
eddof13 has joined #ruby
xdminsy has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
eddof13 has quit [Ping timeout: 256 seconds]
rvalue has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
szkl has joined #ruby
Paris has quit [Ping timeout: 245 seconds]
rvalue has joined #ruby
ht_ has joined #ruby
_ht has quit [Ping timeout: 252 seconds]
ht_ is now known as _ht
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
<ih8u>
adam12: what exactly is the point of `r.up?`?
<ih8u>
i mean, how is it meant to be used?
kenichi has quit [Remote host closed the connection]
kenichi has joined #ruby
kenichi has quit [Changing host]
kenichi has joined #ruby
<adam12>
ih8u: You can return partial responses to Unpoly, if Unpoly has only asked for a certain component. ie. if you had a very expensive sidebar to render (list of product groups or something), you can only render it out if Unpoly had asked for it (<% if r.up?(".sidebar") %><sidebar here<% end %>)