kensanata / mastodon-archive

Archive your statuses, favorites and media using the Mastodon API (i.e. login required)
https://alexschroeder.ch/software/Mastodon_Archive
GNU General Public License v3.0
358 stars 33 forks source link

HTML export to use cropped, centered images #101

Open kensanata opened 1 year ago

kensanata commented 1 year ago

As discussed here: https://github.com/kensanata/mastodon-archive/pull/100

lightnin commented 1 year ago

Is this also where we should describe the need to handle the various configs of 1,2, and 3 images in a way that's similar to how Mastodon handles multi-image toots? Here's how mine stand currently.

Screenshot 2023-05-02 at 08 15 08
kensanata commented 1 year ago

Yeah. I want something like this:

 +-------------------------+
 |                         |
 |                         |
 |                         |
 |                         |
 |                         |
 +-------------------------+
 +------------+------------+
 |            |            |
 |            |            |
 |            |            |
 |            |            |
 |            |            |
 +------------+------------+
 +------------+------------+ +--------+--------+--------+
 |            |            | |        |        |        |
 |            |            | |        |        |        |
 |            +------------+ |        |        |        |
 |            |            | |        |        |        |
 |            |            | |        |        |        |
 +------------+------------+ +--------+--------+--------+
 +------------+------------+
 |            |            |
 |            |            |
 +------------+------------+
 |            |            |
 |            |            |
 +------------+------------+
 +------------+------------+
 |            |            |
 |            |            |
 +------------+------------+
 |            |            |
 |            |            |
 +------------+------------+
 |            |            |
 |            |            |
 +------------+------------+

Not sure about how to layout 5. :)

lightnin commented 1 year ago

That looks great to me. Seems like it should be possible to find and copy whatever code does this in the mastodon source? I've never sniffed around and won't have time to now (still got a few chapters to write)... but theoretically it's there.....

kensanata commented 1 year ago

I think the core code change is in html.py. Currently we only differentiate between "one" media attachment and "more". The code passes "one" or "more" to the media_template which uses it as a CSS class. Everything else, ideally, would happen in CSS.

        media = media_template % (
                'more' if len(attachments) > 1 else 'one',
                ''.join(previews))

I think the solution would be to change the code to use classes "one", "two", "three", "four" and "more", and then just write more CSS.

Currently, there's this:

.more a {
        max-width: 50%%;
        max-height: 50%%;
        display: block;
}

If you have one, height and width should be 100%. If you have two, height should be 100%. If you have three, the first one should have height 100%. And so on. At least that's my naive approach.