206
submitted 8 months ago by kota@hexbear.net to c/technology@hexbear.net

My phone barely manages to load the site. Pages crash and when they do load it's around 10-15 seconds. Pretty much all newer js-dependant websites are like this for me. I simply don't use most newer websites on my phone. Maybe eventually I'll buy a new phone, but things work fine on my laptop so I mostly use that and having a phone from this decade is bourgeois decadence.

A while back I thought maybe I should take a crack at writing a fast and simple read-only frontend that I can use on my phone similar I guess to nitter, invidious, bibliogram, etc.

So I went ahead and did just that: https://diethex.net

Hilariously, I actually wound up doing this TWICE. The first time I finished it up last June and then the site migrated to lemmy v3 so I had to rewrite almost everything which I just now got around to this month. Here's the code in case anyone wants to read it: https://git.sr.ht/~kota/hex

When a page is requested all of its data (comments, posts, etc) are cached for the next 20 minutes which dramatically reduces requests to the actual website when you're browsing around. Also every page is statically generated from simple html templates on the server; so javascript isn't required. I wound up adding a tiiiny bit of optional js to allow opening and closing comments. So you can swipe to the left on a phone to close a comment.

If hexbear is already fast for you then there's no point in using this, but figured I'd say something in case there's anyone else with my issues.

you are viewing a single comment's thread
view the rest of the comments
[-] bdonvr@thelemmy.club 41 points 8 months ago

Hot damn that is responsive. I'm a Lemmy admin, is there an easy way to get this going for my instance? Docker container maybe?

Excellent work, comrade.

[-] YearOfTheCommieDesktop@hexbear.net 26 points 8 months ago* (last edited 8 months ago)

Alrighty, here's what I've got

FROM golang:1.21

WORKDIR /app
COPY . ./

RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -buildvcs=false .

EXPOSE 4000

ENTRYPOINT ["/app/hex"]
#CMD ["-hb","https://lemmygrad.ml/api/v3/"] #Optional

basically just clone the repo, cd into it, create a file with the above lines in it called Dockerfile (uncomment and change the instance base URL if you want to), and then run some docker commands like this:

sudo docker build --tag diethex .
sudo docker run -d --publish 4000:4000 diethex

Then you should be running on port 4000 to test out. Then map the port however you need it and pipe a subdomain to it using nginx as needed.

Oh and if you want to change the title, remove the taglines, etc, you'll need to edit the page templates in files/... It should be pretty straightforward to just change the title/header and remove the MOTD/taglines. I did it but only for the main page.

[-] kota@hexbear.net 22 points 8 months ago

Incredible! That's pretty much what I was gonna say. Might throw this dockerfile in the extras folder.

Yea the hexbear specific stuff basically boils down to the taglines, the emojis, and the header in home.tmpl. There's quite a few things I could do to make it a lot easier to use for other lemmy instances ... there's not a lot of configuration right now, but I tried to leave a lot of comments in the code.

[-] YearOfTheCommieDesktop@hexbear.net 16 points 8 months ago* (last edited 8 months ago)

it was built for a purpose and it accomplishes that swimmingly! and yeah feel free to do whatever with the dockerfile, hope people get some use out of it. I think the templates are simple enough that people can just do their own cosmetic changes but if you have ideas...

also for the dockerfile, copying in the entire repo contents probably isn't the most elegant thing but it was being annoying when I tried to do it other ways

[-] bdonvr@thelemmy.club 10 points 8 months ago

Thanks a lot! I just haven't been home to mess with it yet.

[-] YearOfTheCommieDesktop@hexbear.net 16 points 8 months ago* (last edited 8 months ago)

Okay I got bored and decided to play with it. I got it running in a docker pretty easily, going to see how well pointing it at other instances works now. Will post Dockerfile and results.

Edit: okay, it works fine pointed at a non-hexbear instance (and you don't need to edit code, it's a command line flag.) Buuuut, the title still says diet hexbear and the taglines are all still hexbear's

[-] BountifulEggnog@hexbear.net 26 points 8 months ago

the taglines are all still hexbear's

This seems like a feature

[-] YearOfTheCommieDesktop@hexbear.net 16 points 8 months ago

You could do it but you'd have to be willing to do some of the docker stuff yourself. it shouldn't be too hard, just writing a dockerfile that installs the deps and the compiled app and runs it. OP is running it as an openrc service so that doesn't (likely) help you. some hexbear specific stuff is hardcoded but not a ton I don't think.

And of course you'd have to change the baseurl in hb/hb.go

this post was submitted on 16 Mar 2024
206 points (100.0% liked)

technology

23313 readers
118 users here now

On the road to fully automated luxury gay space communism.

Spreading Linux propaganda since 2020

Rules:

founded 4 years ago
MODERATORS