<FromGitter>
<Blacksmoke16> can have your runs with a higher priority so it runs before the default implementation, which could either always handle it, or like check if its a specific type/interface first, or `Accept` header or whatever
<oprypin>
Blacksmoke16, thanks! can my controller `yield`?
<FromGitter>
<Blacksmoke16> yield what?
<oprypin>
instead of `return`, `yield`
<FromGitter>
<Blacksmoke16> neg
<oprypin>
egh too much python nevermind
<FromGitter>
<Blacksmoke16> 👍
<oprypin>
Blacksmoke16, sorry for another super lazy one.. any way to get a URL back from a controller name?
<oprypin>
and args
<FromGitter>
<Blacksmoke16> not atm, but will be working on something to enable that coming up
<oprypin>
oof
<oprypin>
thanks
<FromGitter>
<Blacksmoke16> prob could hack together a workaround for now
<oprypin>
easier to just write them out
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<Blacksmoke16> tl;dr need to decuple some things internally to expose the routes
<FromGitter>
<Blacksmoke16> decouple*
<FromGitter>
<Blacksmoke16> its next up after the query param enhancements
duane has quit [Ping timeout: 240 seconds]
duane has joined #crystal-lang
<oprypin>
Blacksmoke16, am i going crazy or does the getting started guide not show how to return html?
<oprypin>
also actually i didnt understand the view stuff. seems like im supposed to register it globally but i want just for one controller
<FromGitter>
<Blacksmoke16> one controller, or one controller method?
<oprypin>
one controller actually in this case
<oprypin>
this "listeners" stuff is not clear how to approach at all
<FromGitter>
<Blacksmoke16> in that case id argue you dont really need the view stuff, just a private helper method that each action can use, passing the object to that helper method
<FromGitter>
<Blacksmoke16> the view listener/event is a global construct. It would be something that you could setup to handle a specific way to return a response. Like you could have one that checks if the request accepts HTML and somehow renders the returned value as html
<oprypin>
so hear me out
<FromGitter>
<Blacksmoke16> if you dont need something at that high of a level, having a private helper method to handle the creation of the `ART::Response` would also be valid
<oprypin>
just as a shorthand, make some functionality that wraps all responses within a controller into a new class, and then also registers a listener for that class, with the passed block
<FromGitter>
<Blacksmoke16> i guess a good question to ask is what are you wanting to do the data returned by each of the actions in this controller?
<oprypin>
turn it into html
<FromGitter>
<Blacksmoke16> like rendering a template based on some data or something like that?
<oprypin>
yea. like the view for the controller, u know
<FromGitter>
<Blacksmoke16> is the view using ECR?
<oprypin>
not using anything atm. raw crystal or ecr is fine
<FromGitter>
<Blacksmoke16> because you could just have a helper method that abstracts some of this
<oprypin>
nah screw that, i want my controllers to return data
<oprypin>
i actually have a reason for that but i'll get into that later
<oprypin>
anyway i think i solved it
<FromGitter>
<Blacksmoke16> yea in that case you'd need a view listener, as thats whats responsible for converting the non `ART::Response` into an `ART::Response` object
<FromGitter>
<Blacksmoke16> which would essentially be doing the same thing tbh
<FromGitter>
<Blacksmoke16> but ofc be more generic/reusable
<oprypin>
figured out the html stuff
<oprypin>
(right before you sent the example, but thanks :p)
<FromGitter>
<Blacksmoke16> :p np
<oprypin>
i think you should just switch out .css to .html in the example
<FromGitter>
<Blacksmoke16> prob wouldnt hurt adding a little section about it
<FromGitter>
<Blacksmoke16> point was to show that it can be used to return whatever raw data you want
<FromGitter>
<Blacksmoke16> but HTML would show that point just as well and prob be more common
<FromGitter>
<Blacksmoke16> of a use case*
<oprypin>
mm there's QueryParam but no FormParam :D
<FromGitter>
<Blacksmoke16> theres a branch/commit that you could use that has that, its functionally done just working on specs/docs atm
<FromGitter>
<Blacksmoke16> could prob look into a param convert for that particular controller
<FromGitter>
<Blacksmoke16> er nvm, not really. Still need the raw data it looks like
<oprypin>
thats what im saying
<oprypin>
without this mechanism, each individual method would have to have its "raw" twin
<FromGitter>
<Blacksmoke16> and oo, you're calling the other routes from the one route? :thinking:
<oprypin>
thats the kicker
<oprypin>
[02:09:23] <oprypin> i actually have a reason for that but i'll get into that later
<oprypin>
also really unsure about the parts `ART::Events::View => 25` and `if (result = event.action_result.as?(Result))` [else do nothing at all]
<FromGitter>
<Blacksmoke16> i think youd want to make it more than 25 so it runs before the default one, then prob do like `return unless (result = event.action_result).is_a? Result`?
<oprypin>
*more*? reverse priority again 😩
<FromGitter>
<Blacksmoke16> higher value == higher priority no?
duane has quit [Ping timeout: 240 seconds]
<oprypin>
actually nevermind, this one is probably more common
<FromGitter>
<Blacksmoke16> thoughts on maybe extracting the links logic to another type? then your actions would be like `@link_provider.by_branch` etc
<FromGitter>
<Blacksmoke16> i feel like that would be less of a hack, and easier to test
<oprypin>
sure. but then whats the point of a controller
<oprypin>
like seriously, why are we putting those methods into separate classes
<FromGitter>
<Blacksmoke16> makes things more testable and removes the need to directly invoke other controller actions
<oprypin>
mm i'm getting `undefined constant Result` if I use it without fully writing out `ArtifactsController::Result`, even though this is inside `ArtifactsController`
<FromGitter>
<Blacksmoke16> prob since the type itself isnt instantiated directly in that namespace, so it doesnt know about it
<oprypin>
Blacksmoke16, i mean i literally don't understand for the purpose of Athena, if i have 5 methods, why would I not put them into 5 separate classes / why would I not put them into 1 class ?
<FromGitter>
<Blacksmoke16> no no, sorry if i wasn't clear. I was proposing you have 1 class that has methods like `by_branch`, `by_run`, `by_artifact`, then the related controller actions calls the related method, which internally could call the other methods in a less hacky way
<FromGitter>
<Blacksmoke16> it just feels strange to directly invoke other action methods like that
<oprypin>
i get this but my question stands
<oprypin>
i could have those methods *at top level*
<oprypin>
then i could have controller methods also at top level, if athena didnt require putting them into a class
<oprypin>
what does having a class accomplish here?
<FromGitter>
<Blacksmoke16> ability to inject other services via DI
<FromGitter>
<Blacksmoke16> which makes testing and reuse easier
<oprypin>
are instance variables ever useful?
<FromGitter>
<Blacksmoke16> when used with DI yes, as the injected services would be instance vars
<FromGitter>
<Blacksmoke16> which allows you to base the functionality of the controller on a public interface API (that could be mocked for testing). While also making it easier to test the logic that generates these links objects in isolation
<oprypin>
👍
<FromGitter>
<Blacksmoke16> im not disagreeing that it adds some complexity/different ways of thinking compared to other frameworks, but i try to nudge people to keeping SOLID principles in mind
<FromGitter>
<Blacksmoke16> in the end it'll make maintaining, testing, and reading the code much easier in the long run
<FromGitter>
<Blacksmoke16> also fwiw, the `Result` type doesn't need to inherit from the `Event` type since you're not using it as an event
<FromGitter>
<Blacksmoke16> its just a domain type
<oprypin>
ah yes. i was bound to miss something with how much scrambling i had there
<oprypin>
Blacksmoke16, mostly i just literally have no idea what is possible with athena
<oprypin>
really needs a "book" style doc
<FromGitter>
<Blacksmoke16> now that would really be a book ha
<FromGitter>
<Blacksmoke16> i think theres also just different programming styles at play, when comparing Ruby, and Crystal by extension, compared to like Java/PHP
<FromGitter>
<Blacksmoke16> like at work the DI and single responsibility principles are quite well know and we always try to design things following those patterns
<oprypin>
did u just say that php has better practices than ruby
<oprypin>
well i suppose it does
<FromGitter>
<Blacksmoke16> while in Ruby land those concepts dont seem to be as pronounced
<FromGitter>
<Blacksmoke16> PHP as an OOP lang is pretty good, PHP as a lang itself not so much
<oprypin>
im aware of those, of course, but in this context i'm 1) not at work, intentionally having _fun_ 2) dont know about them in the context of athena
<FromGitter>
<Blacksmoke16> yea its all good, point i was trying to make is i think theres some overlap in needing to explain/demonstrate these concepts versus assuming everyone is aware of them. Mainly for those coming from Ruby land
<FromGitter>
<Blacksmoke16> which is deff where some docs going over that higher level introduction might be helpful
<FromGitter>
<YusufCakan> What would be the easiest way to automatically put parenthesis around all the function call sites (or at least identify the function) in a piece of code.
<FromGitter>
<YusufCakan> I meant to say "or at least identify the call sites in a piece of code"
daemonwrangler has quit [Ping timeout: 246 seconds]
* raz
sigh of relief
<raz>
achhh.... coming back to crystal after a day of go-lang is like a warm bath
<FromGitter>
<naqvis> go-lang isn't that bad :P
<raz>
yes it is.
<jhass>
maybe you should do javascript for a day before going back to Go :D
<raz>
honestly, i can tolerate javascript better than go nowadays. at least it let's you write relatively straightforward code (just gotta watch out for all the footguns). and with typescript it's actually becoming somewhat bearable.
<raz>
the sheer uglyness of go still repels me from the first keystroke to the last :<
<jhass>
ah, I'm sure we can find something where Go becomes the relief :D
<jhass>
PHP? VisualBasic?
<raz>
heh... try harder :p
<raz>
PHP is bad but at least practical...
<jhass>
implementing TLS with OpenSSL rather than whatever Go's package is called
<jhass>
Oh, I know, a day of ABAP
<raz>
well yea people use Go for all kinds of system tools and the results tend to be not bad. the two things it has going for it is that it's fast and doesn't leak
<raz>
i've never used ABAP but heard ppl say it's actually not *that* terrible for what it is
<raz>
syntax-wise it looks sql'ish to me hmmm
<raz>
and really aesthetics-wise i find that still more pleasant than the go line noise
<jhass>
hey, the scenario is you have to do it for a day and then you can go back to doing Go and how you feel. Not whatever people say :P
<raz>
like who on earth decided that public stuff should be uppercase
<raz>
well, i heard SAP coders are paid quite well
<raz>
that could offset some of the pain :D
<jhass>
well, Dart uses "prefix with _" to make methods private. Gotta have quirks everywhere
<raz>
at least that limits the uglyness to the rare parts where it's actually needed
<FromGitter>
<naqvis> and Nim uses `*` to mark things public :P
<jhass>
I tend to have more private than public methods, in Flutter code at least
<raz>
whereas go smears it in your face in every line
<erdnaxeli>
go works, but it is boring
<jhass>
that's quite its intend as I understood it, to be boring
<raz>
naqvis: yes but only at declaration. you don't have to include it in every call i think?
<erdnaxeli>
jhass: indeed
<raz>
i'm fine with boring. but not with tedious and ugly.
<erdnaxeli>
the thing that really blocked me when doing go is not having union types
<raz>
well, they're adding generics now. but the syntax is... yet more line noise of course
<FromGitter>
<naqvis> generics got added after whole lot of wars and debates
<FromGitter>
<naqvis> but yeah there is always never-ending wars on languages, tools ....
<FromGitter>
<naqvis> a vs b, vim vs emacs
<FromGitter>
<naqvis> and people really get religious on such wars :P
<raz>
yup and all that even tho the answer is so simple. vim is obviously right and emacs just wrong. ¯\_(ツ)_/¯
<straight-shoota>
amen
<yxhuvud>
shrug. both are great.
<yxhuvud>
(in very different ways)
kreyren has quit [Remote host closed the connection]
kreyren has joined #crystal-lang
kreyren has quit [Remote host closed the connection]
<FromGitter>
<tenebrousedge> now I'm very confused
<FromGitter>
<domgetter> Are there any resource on how to use `Compress::Zlib`? The docs don't show any examples, and I don't even know what to `require` to try and use it.
<jhass>
DeBot was the Ruby version. I don't pretend I remember the reason for the name...
<FromGitter>
<tenebrousedge> @domgetter there does seem to be some missing docs there. However, there seems to be a lot of specs covering compression
<FromGitter>
<domgetter> Can you point me to those specsa?
<FromGitter>
<Blacksmoke16> ah yea this method happens outside of the request lifecycle, i.e. its only provided static/global config
<kreyren>
alternatively github.com/iv-org/invidious whe i've changed deployment and utils.cr in src/invidious/helpers
<kreyren>
Blacksmoke16 So calling file outside of the main file causes the variable to not be available?
<FromGitter>
<Blacksmoke16> no let me be more clear, this method executes when invidious runs to set the `HOST_URL`
<FromGitter>
<Blacksmoke16> i.e. it doesnt happen when you make a request to invidious
<FromGitter>
<Blacksmoke16> thus, you dont have access to `env` since your not in a request context
<kreyren>
ah i though it would be available during that runtime x.x what do you suggest then assuming https://github.com/iv-org/invidious/issues/1421 being the issue that i am trying to fix?
<FromGitter>
<Blacksmoke16> based on the discussion i read yesterday there is a solution, you cant rely on `HOST_URL` constant and need to determine what it is on a per request basis
<kreyren>
The issue with that is that this is expcted to be provided on clearweb and Tor so the HOST_URL is expected to expand accordingly.. but thinking about it i think that relative paths would be better solution here?
<FromGitter>
<Blacksmoke16> im not sure, i only skimmed the discussion/that issue
<kreyren>
i see O.o well let me try to see what happens then
<FromGitter>
<Blacksmoke16> maybe go back and go thru the discussion again
<jhass>
you're still trying to preserve HOST_URL. It has to die. Entirely.