bibanon / BASC-Archiver

Python-based Imageboard (4chan) complete thread archiver.
https://pypi.python.org/pypi/BASC-Archiver/
135 stars 18 forks source link

add jinja2 templating #36

Closed HuggableSquare closed 5 years ago

HuggableSquare commented 8 years ago

I have jinja2 templates functional, but definitely not complete yet.

I will list the current issues:

That's all I can specifically remember as issues, but I'm opening this pull request so that we can discuss our options, and work on fixing the issues.

antonizoon commented 8 years ago

Awesome. This has been a big feature we have wanted for a while. Keep working at it.

The standard CSS/JS can just be copied to the root of the archive/4chan/ , except in circumstances where you want to save custom CSS/JS (like the recent April fools Material Design).

DanielOaks commented 8 years ago

Honestly, I'd probably prefer embedding the CSS/JS into the html file directly (or at the least, contained in the thread folder), to prevent bad things from happening when we do update css/js/the html templates themselves.

wrt the JS, with the Jinja2 templates I think we should be building our own block of JS rather than using the downloaded 4chan ones directly. Feel similarly about the CSS honestly, since these templates are intended to be used between different site archivers (later down the track, at least).

Thanks for the PR, it's much appreciated!

DanielOaks commented 8 years ago

By the way, the JS not working issue is likely due to browsers disabling the ability to grab JS from file: URLs, fairly standard security junk. Embedding the JS directly into the page will let it work whether served from a webserver or just by double-clicking on the HTML file, which should make things nicer for users.

HuggableSquare commented 8 years ago

Embedding the JS and CSS into the html file directly is nearly impossible seeing as the native 4chan extension is nearly 10k lines, but I guess theoretically putting it in every single thread folder is an option albeit you would have a copy of the exact same file over and over.

I'm not actually using directly downloaded JS, I'm using a modified (albeit slightly) version of the 4chan native extension for use with the archiver. Using the directly downloaded JS doesn't work because the JS looks a lot at the format of the URL. Specifically it matches it based on a pattern that goes domain.com/board/thread/tid to get info such as the tid and board (also why I removed the self.name sub in). So, even if we were to embed it into the html directly, it still wouldn't work without a webserver hosting it at a specific directory.

Theoretically I'm guessing there are large parts of the extension that could be removed/refactored to rely less on the actual 4chan.org domain, and using a webserver in general, but I'm 100% not that handy in JS, and rewriting a 10k line extension is a task I'm definitely not up for, especially because I personally have a system that works for me.

DanielOaks commented 8 years ago

Hmm, that's fair. Do you have that javascript file anywhere for reference? I'll probably have a go at rewriting something that provides similar functionality for the downloaded threads.

DanielOaks commented 8 years ago

I may end up pulling this into the repo as the 'templating' branch to make it easier for us to work on, thoughts? Once it's deemed done we can pull it into master, and in the meantime PRs can be submitted to that branch.

HuggableSquare commented 8 years ago

Here's the version of the extension js that I've been using. https://github.com/HuggableSquare/jinjaChan/blob/master/js/extension.1014.js

I've gotten it to work, but it still throws errors because it tries to load things like thread stats from the 4cdn domain. It's quite a complicated js file, but I'm trying to see what sections I can just remove entirely or rework.

On the topic of pulling it in as the templating branch, I don't see any issue with that. I'm no git wizard, but if that makes working on it easier then go for it.

vxbinaca commented 6 years ago

what's being done with this?

antonizoon commented 6 years ago

It's pretty cool i suppose, but until dan_ gets around to fitting that javascript in some way it will be of limited use.