lionleaf / dwitter

Social network for short js demos
https://www.dwitter.net
Apache License 2.0
763 stars 69 forks source link

Automatic decompression #517

Closed willhansen closed 2 years ago

willhansen commented 3 years ago

With the advent of dweet compression, the code is even less readable. Could we display the uncompressed code if specific compression methods are detected?

KilledByAPixel commented 3 years ago

That would be cool! I've already hooked that up on http://dweetview.3d2k.com/ and http://dweetabase.3d2k.com/ for reference.

ThomasBrierley commented 3 years ago

The recent performance update actually does this internally, and it turned out to be pretty safe. I think the only consideration is UX... if we do this automatically then it might seem a bit strange to newbies that some dweets are magically 194 characters. The possible ways to address this are either a secondary indication of some kind, or to make the decompression an explicit user action i.e a "decompress" button.

lionleaf commented 3 years ago

I agree, this would be neat, but I worry about the UX. I much prefer that it's an explicit action, like a "decompress" button, as @ThomasBrierley mention.

Maybe it should come with an optional explainer pop up that explains how the compression works?

At that point do we add a "compress" button as well?

ThomasBrierley commented 3 years ago

Maybe it should come with an optional explainer pop up that explains how the compression works? At that point do we add a "compress" button as well?

It's already quite hard to refrain from bumping up to 194 for me as a regular user, would a button make it too tempting and also too easy for newbies to appreciate the extra step involved?

Perhaps a link to a short explanation to read could act as a good "rite of passage"... maybe I am just in denial, it's true those extra 54 characters really open up the possibilities, but its still impressive when someone manages to cram something new and unique into 140 occasionally.

Option 3: Only add a decompress button, leave it as something to discover.

lionleaf commented 3 years ago

If anyone is interested in taking on this, I'd be in favor of starting of with just a decompress button. Ideally subtle, and only visible when there is something to decompress. I think just replacing the code with the decompressed code might be ok?

Alternatively spit out the decompressed code below in a similar fashion to the "throw" trick

ThomasBrierley commented 2 years ago

I think we really do need to do something here, anything to make it clear what's under the encoding. I'll give this a go when I get an evening.

I believe presenting those outside of dwitter with a wall of unicode glyphs affects their appreciation and thus interest more than we realise. One of my colleagues initially thought the challenge was in encoding the unicode chars manually - which might sound silly, but you can imagine how offputting that sounds as a challenge.

sigvef commented 2 years ago

I completely agree!

Incidentally, I was experimenting a bit with what that could look like in https://github.com/dwitter-net/dwitter-frontend (https://beta.dwitter.net), and this is what I came up with:

 

If there is interest I can package it up and start making some pull requests!

KilledByAPixel commented 2 years ago

I like the mockup! It would be great to have this as a feature, I'm sure seeing all this compressed code is confusing to novices.

lionleaf commented 2 years ago

This feature is now live on beta.dwitter.net! Check it out.

Implemented in this PR: https://github.com/dwitter-net/dwitter-frontend/pull/81

I'll keep this issue open for a bit longer to allow for feedback and further discussion.

ThomasBrierley commented 2 years ago

I like it.

Looking forward to the beta becoming the primary frontend.

lionleaf commented 2 years ago

This is now live and functional. Closing issue :)

KilledByAPixel commented 2 years ago

Not sure why but compressing this dweet causes a crash (i assume because of non ascii characters)

https://dwitter.net/d/24278

In CapJS I added some extra stuff to replace any unicode characters so compression still works. Feel free free to use this as a starting point...

    // replace unicode characters
    const codeIn = [...codeMirrorEditor.getValue().trim()];
    let code = '';
    for (let character of codeIn)
    {
        const charCode = character.charCodeAt(0);
        if (charCode > 255)
            character = escape(character).replace(/%u/g,'\\u');
        code += character;
    }
lionleaf commented 2 years ago

Yeah, @CiaccoDavide just fixed that but I haven't deployed it yet: https://github.com/dwitter-net/dwitter-frontend/pull/100

That snipped might be helpful as well. Thanks!

lionleaf commented 2 years ago

Deployed. Now it just gives you a warning which is more helpful than the old crash. But that particular dweet is still causing issues

lionleaf commented 2 years ago

Continue discussion here: https://github.com/dwitter-net/dwitter-frontend/issues/107