Skip to content

feat: add web bundle as download option#241

Merged
roedoejet merged 11 commits intomainfrom
dev.ap/zip
Apr 2, 2024
Merged

feat: add web bundle as download option#241
roedoejet merged 11 commits intomainfrom
dev.ap/zip

Conversation

@roedoejet
Copy link
Copy Markdown
Collaborator

@roedoejet roedoejet commented Mar 14, 2024

Here's a first stab at this. A few things:

  • The web preview should work if you want to try it out (select "web bundle" from the download format options)
  • I don't love how much logic is in the demo.component.ts I can live with this for now, but I think we're due for some refactoring
  • Maybe we should come up with a better basename than just output since if people are combining multiple readalongs they'll have to rename everything. timestamps?
  • The assets folder stuff needs to be improved. We have the use-assets-folder property, but the value is just a boolean. I think we should instead have that be a path that could get prepended to all images, because right now, the images are hardcoded in the .readalong file as being in an assets folder relative to the location of the ReadAlong, which is sure to break in many deployments. Update: see fix(assets)!: get rid of useAssetsFolder boolean and replace with imageAssetsFolder string #243
  • looks like we need to run prettier on everything. I didn't do that here yet, to make sure the content changes are easily parsable.
  • Translations for french and spanish still have to be added

@roedoejet roedoejet marked this pull request as draft March 14, 2024 19:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 14, 2024

PR Preview Action v1.4.7
🚀 Deployed preview to https://ReadAlongs.github.io/Web-Component/pr-preview/pr-241/
on branch gh-pages at 2024-04-02 22:24 UTC

@roedoejet roedoejet force-pushed the dev.ap/zip branch 2 times, most recently from 153d2cc to ef8fa1c Compare March 14, 2024 19:22
@roedoejet roedoejet marked this pull request as ready for review March 14, 2024 19:26
@roedoejet roedoejet requested review from dhdaines and joanise March 14, 2024 19:26
@joanise
Copy link
Copy Markdown
Member

joanise commented Mar 15, 2024

More comments, now that I have tested this feature.

File names:

  • readalong.zip would be better than output.zip, more self-documenting.
  • Ditto the files in assets/ in the archive, assets/readalong.{mp3,readalong} would be better than assets/output.*.
  • output.txt is confusing, since it's really the input text. readalong.txt would be OK, or maybe input.txt.

The README.txt file should be outdented against the left margin. My guess is you have it indented probably because of the file where you're defining its contents, but I don't like the result, it ought to start on the first line (remove the blank line) and have no indents. It should also be wrapped at <=79 characters. I know we don't do that anymore in code, but here when I double clicked on the file the display was awful at 80 chars wide.
image
I would also be OK with no manual wrapping at all, letting the auto-wrapping do its thing, but pre-wrapped at 107 yields poor results if the window is even slightly narrower. Between not pre-wrapped at all, and pre-wrapped at 79, I can't decide what I prefer: not pre-wrapped adjusts to whatever window size the user has, 79 is old machine friendly, though maybe not mobile friendly... You pick!
Key is, I'd like the default display to be easy to read on all OSes, machine ages, and user defaults.

@joanise
Copy link
Copy Markdown
Member

joanise commented Mar 15, 2024

I tested unzipping the file on my machine and running python -m http.server, and that works nicely.

One thing, though, this is a zip bomb, with no inner folder. Would it make sense to put all the contents in a readalong/ folder inside the zip file? Or is it just because I'm a developer that I'm allergic to tar bombs?

Comment thread packages/studio-web/src/app/demo/demo.component.ts Outdated
};
outputFormats = [
{ value: "html", display: $localize`Offline HTML` },
{ value: "zip", display: $localize`Web Bundle` },
Copy link
Copy Markdown
Member

@joanise joanise Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zipped Web Bundle?
That would give me "Fichiers Web zippés" and "Archivos web comprimidos".
I find just "Web Bundle" insufficiently clear.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some research on "zippés" vs "comprimés" for the French translation, and Google tells me the former is much more common than the latter, and that matches my intuition, but Spanish doesn't seem to have that, it would have to be "Archivos web comprimidos zip" if we wanted to be precise, but I think that's unnecessary, adding more verbosity with no additional clarity, whereas the French "zippés" is shorter and more common, thus a no brainer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mais même selon l'OQLF "zippé" est acceptable dans certains contextes ;-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to be picky, but my first choice is "zippé" because we're creating an actual .zip file.

Does anyone have an opinion on the English, though, whether we should add "Zipped" in front?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "zipped" is redundant - Bundle implies that it's bundled/zipped which is sufficient

@joanise
Copy link
Copy Markdown
Member

joanise commented Mar 15, 2024

By the way, we already applied prettier:

$ npx prettier -c packages
Checking formatting...
All matched files use Prettier code style!

the generated index.html file is not prettier'd, though, that's true.

@dhdaines
Copy link
Copy Markdown
Collaborator

The README.txt file should be outdented against the left margin. My guess is you have it indented probably because of the file where you're defining its contents, but I don't like the result, it ought to start on the first line (remove the blank line) and have no indents. It should also be wrapped at <=79 characters. I know we don't do that anymore in code, but here when I double clicked on the file the display was awful at 80 chars wide.

black wraps at "90-ish" so we do this in code, more or less. I think it is reasonable to wrap at 80 (if you use Emacs it is as simple as typing Esc-q) as this makes the text easier to read in general (there's a reason why LaTeX makes wide margins). If you don't wrap lines then not everbody's terminal/browser/whatever is going to actually word wrap correctly in any case.

@dhdaines
Copy link
Copy Markdown
Collaborator

One thing, though, this is a zip bomb, with no inner folder. Would it make sense to put all the contents in a readalong/ folder inside the zip file? Or is it just because I'm a developer that I'm allergic to tar bombs?

Yes, I think this is a good idea - MacOS or Windows are going to unpack it in a new folder anyway, but this way nobody gets any nasty surprises.

Copy link
Copy Markdown
Collaborator

@dhdaines dhdaines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good, mostly style comments.

Comment thread packages/studio-web/src/app/demo/demo.component.ts Outdated
Comment thread packages/studio-web/src/app/demo/demo.component.ts Outdated
Comment thread packages/studio-web/src/app/soundswallower.service.spec.ts
Comment thread packages/studio-web/src/app/upload.service.ts
Comment thread packages/studio-web/src/app/upload/upload.component.ts Outdated
Comment thread packages/studio-web/src/app/upload/upload.component.ts Outdated
Comment thread packages/studio-web/src/app/demo/demo.component.ts Outdated
Comment thread packages/studio-web/src/app/demo/demo.component.ts Outdated
@roedoejet roedoejet requested a review from joanise March 19, 2024 16:39
Copy link
Copy Markdown
Member

@joanise joanise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now.

Copy link
Copy Markdown
Collaborator

@dhdaines dhdaines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! sorry for the delay in approving!

@deltork
Copy link
Copy Markdown
Collaborator

deltork commented Mar 28, 2024

can the readme contain section about deployment on wordpress, with the apporpiate snippet :
[wp_read_along_web_app_loader version='^1.2.0'] <read-along...></readalong> [/wp_read_along_web_app_loader]

@joanise
Copy link
Copy Markdown
Member

joanise commented Mar 28, 2024

can the readme contain section about deployment on wordpress, with the apporpiate snippet :
[wp_read_along_web_app_loader version='^1.2.0'] <read-along...></readalong> [/wp_read_along_web_app_loader]

Absolutely, just add that in your PR.

@deltork
Copy link
Copy Markdown
Collaborator

deltork commented Apr 2, 2024

can the readme contain section about deployment on wordpress, with the apporpiate snippet :
[wp_read_along_web_app_loader version='^1.2.0'] <read-along...></readalong> [/wp_read_along_web_app_loader]

Absolutely, just add that in your PR.

The readme is only in this branch. I will have to add the instructions after this branch is merged

.toISOString()
.replace(/[^0-9]/g, "")
.slice(0, -3);
const basename = `readalong-${timestamp}`;
Copy link
Copy Markdown
Collaborator

@deltork deltork Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When people provide a title, adding the title to the filename will help them find it after download, especially if they do multiple books.
const basename = (this.slots.title?this.slots.title.replace(/\s/g,"_").toLowerCase():'readalong')+`-${timestamp}`;

@roedoejet roedoejet force-pushed the dev.ap/zip branch 2 times, most recently from 38a0c7c to 0714343 Compare April 2, 2024 20:22
.replace(/[^0-9]/g, "")
.slice(0, -3);
const basename =
(this.slots.title ? slugify(this.slots.title, 15) : "readalong") +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, except it's too anglocentric: if the title is ᐃᓄᒃᑎᑐᑦ, the slug is empty and you get -20240402212031.zip, and the .txt file inside is similarly limited. Similarly "Éric" becomes "ric", but the Inuktitut example is a lot more dramatic. Can we slugify the text-unidecode output, maybe?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this @joanise - I've updated it to use unidecode

roedoejet and others added 11 commits April 2, 2024 15:17
	- Update $ style for rxjs variables
	- Add inner folder for zip
	- Use timestamps for filenames
	- Remove indentation for readme
	- Added explicit version for unpkg import
	- Added error handling for zip download promise
…geAssetsFolder string

BREAKING CHANGE: useAssetsFolder is no longer valid.

The equivalent is imageAssetsFolder='assets/' which is the default.
@roedoejet roedoejet merged commit 2df8ef0 into main Apr 2, 2024
@roedoejet roedoejet deleted the dev.ap/zip branch April 2, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants