Code Monkey home page Code Monkey logo

Comments (5)

jshph avatar jshph commented on May 27, 2024 1

Hi, I believe I have a similar issue and can offer some more perspective: if I pass a directory to staticrypt, and there are css files in that directory, staticrypt will attempt to encrypt the css files (or any other file) as an HTML file. This causes syntax issues in the resulting css file.

I would prefer if the CSS file were just copied to the new directory (this would work for my use case). Not sure if this is the general case solution though.

Additionally, if there are multiple index.html files that are being passed, they seem to copy to the same file without preserving the original directory structure.

from staticrypt.

robinmoisson avatar robinmoisson commented on May 27, 2024

Hey @Sammeeey, sorry for the late reply and thanks for reporting.

Regarding not finding linked CSS or images: what staticrypt does is encrypt the html file only, and put it in the /encrypted folder. So if your file structure is

encrypted/filename.html
filename.html
style.css
image.jpg

and your original html file links to external files with <style src="style.css">/<img src="image.jpg">, then since the encrypted file is in encrypted/ when you decrypt it it won't find the other files. (it'll look under encrypted/style.css and they're not there)

You can either move the style.css and image.jpg in the encrypted folder, use absolute links to the files (src="/style.css" or src="//mywebsite.com/style.css"), change your structure to have something like

encrypted/filename.html
html/filename.html
assets/style.css
assets/image.jpg

and have relative linking with src="../style.css"... Many different options depending on your setup.

Regarding encryption working once: I don't think I understand exactly what you did here. Why did you delete the .staticrypt.json file, and especially the encrypted/ folder? That folder is where the encrypted file will be.

from staticrypt.

robinmoisson avatar robinmoisson commented on May 27, 2024

Hey @jshph, thanks for commenting and for the good idea.

I think if we pass a directory we could encrypt the .html files et copy everything else as is in the new directory, instead of trying to encrypt other files in a way that doesn't make sense. Seems like this would solve your use case?

That means we're suddenly including files that used to be encrypted as plaintext, but I guess that's not behavior you were supposed to rely on (since the files were unusable), so not a breaking change. I'll sleep on it, happy to hear if others think otherwise.


Regarding the multiple index.html files, can you give more details? If you pass staticrypt foo/index.html foo/bar/index.html that's to be expected, when passing single files staticrypt will get the file, encrypt it and put it at the root of the encrypted directory, so if they have the same name they'll overwrite each other. If you want to preserve a directory structure, you'll have to pass the directory itself as an argument, with the `-r| flag.

from staticrypt.

jshph avatar jshph commented on May 27, 2024

Yes that's exactly it. I consider the ability to pass a full directory as an improvement, but for my use case it needs to only encrypt HTML files. Perhaps others' use cases differ; an "excludes" filter that takes glob arguments could help.

I think I wasn't aware of the -r flag helping to avoid overwriting index.html! I ended up reverting to an earlier version of staticrypt that relies on find... exec for now.

from staticrypt.

robinmoisson avatar robinmoisson commented on May 27, 2024

Done & published! Starting 3.3.2, non-HTML file will be copied as-is.

from staticrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.