Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Zotero 7 #63

Merged
merged 10 commits into from
Mar 26, 2024
Merged

Add support for Zotero 7 #63

merged 10 commits into from
Mar 26, 2024

Conversation

stweil
Copy link
Member

@stweil stweil commented Mar 25, 2024

This pull request adds support for Zotero 7 while still maintaining the support for Zotero 6. It is based on pull request #59. In addition it substitutes the pull requests #61 and #62 and includes some minor fixes and improvements.

aborel and others added 2 commits March 25, 2024 09:26
Zotero 7 can use the image files from Zotero 6, so remove the duplicates.
Remove also whitespace at line endings

Signed-off-by: Stefan Weil <[email protected]>
@stweil
Copy link
Member Author

stweil commented Mar 25, 2024

In the last commit I updated the version to 1.0.0. This is to be discussed. Would you prefer a minor step to 0.7.0?

@stweil
Copy link
Member Author

stweil commented Mar 25, 2024

Open known issues:

  • The preference window is currently not responsive, with text up to or exceeding the right margin.
  • The UB Mannheim icons are nearly invisible on dark mode (MacOS at night) and don't use a design similar to other plug-ins or preference icons which also use SVG instead of PNG.
  • It would be nice to have some feedback about the OCR progress, maybe in an extra window which opens when the OCR is started.
  • The implementation for Zotero 6 still uses the old overlay plugin code. It could be converted to a bootstrapped plugin which would allow re-using some of the new Zotero 7 code.

@aborel
Copy link
Collaborator

aborel commented Mar 25, 2024

Considering the observed issues, I am not 100% sure it deserves 1.0.0, but the choice is yours :-)

@stweil
Copy link
Member Author

stweil commented Mar 25, 2024

I think you are right, so the last commit needs an update before this PR gets merged.

Copy link
Member

@zuphilip zuphilip 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 very much for all these work @stweil and @aborel ! That looks fine for me in general and I tested it in Zotero 7 as well. I have only some questions and small suggestions here.

As for the version number, I would also prefer to have 0.7.0 instead of 1.0.0. The design of the functionalities is for me not so clearly fixed yet and therefore I don't feel that it is already time for the 1.0.0.

I suggest to have the version here for Zotero 6 and 7, but then the focus on Zotero 7 only in the continuation. E.g. there is IMO no need to work on a bootstrap version for Zotero 6. We should just make sure that people with Zotero 6 and 7 can update to this newer version and from then on update even further for future version with Zotero 7. I guess we can do that with two entries in the updates.json.

"update_link": "https://github.com/UB-Mannheim/zotero-ocr/releases/tag/0.0.0/zotero-ocr-0.0.0.xpi",
"update_hash": "sha256:0000000000000000000000000000000000000000000000000000000000000000",
"applications": {
"gecko": {
Copy link
Member

Choose a reason for hiding this comment

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

For what is this tmpl file needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

The template file is used by release.sh to create a new updates.json (and its copy for Zotero 6).

release.sh Outdated

jq ".addons[\"[email protected]\"].updates[0].version = \"${version}\"" updates.json.tmpl |
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't you change the version number in the updates.json file instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that line is part of a command chain which writes a new updates.json. The input for that comes from the template updates.json.tmpl.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@stweil stweil Mar 26, 2024

Choose a reason for hiding this comment

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

You can try the release process locally:

  • Run ./release.sh 0.7.0

Then release it on GitHub:

  • Run git push origin 0.7.0
  • Create new release for 0.7.0 on GitHub
  • Update the locally built zotero-ocr-0.7.0.xpi as asset for the new release

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I see now that jq don't do the changes in-file and therefore a temporary file is needed.

I find these lines a little hard to read and suggest therefore some simplification, like:

jq '.addons["[email protected]"].updates[0].version = "${version}" | 
    .addons["[email protected]"].updates[0].update_link = "https://github.com/UB-Mannheim/zotero-ocr/releases/tag/${version}/zotero-ocr-${version}.xpi" | 
    .addons["[email protected]"].updates[0].update_hash = "sha256:$(shasum -a 256 build/zotero-ocr-${version}.xpi | cut -d\' \' -f1)"' update-extract.json.tmpl \
   > update.json.tmpl
cp update.json.tmpl update.json
rm update.json.tmpl

Moreover, we don't need to commit the temporary file. It should be fine to create this every time and then delete it again.

Copy link
Member Author

Choose a reason for hiding this comment

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

updates.tmpl is not a temporary file. It is a template file which is read as input by jq. In your code jq will read from STDIN because the first jq command has no file argument.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, but we can read this information from the actual updates,json. Thus my corrected suggestion would be:

# update information in update.json using a temporarily file
jq '.addons["[email protected]"].updates[0].version = "${version}" | 
    .addons["[email protected]"].updates[0].update_link = "https://github.com/UB-Mannheim/zotero-ocr/releases/tag/${version}/zotero-ocr-${version}.xpi" | 
    .addons["[email protected]"].updates[0].update_hash = "sha256:$(shasum -a 256 build/zotero-ocr-${version}.xpi | cut -d\' \' -f1)"' update-extract.json.tmpl \
   update.json > update.json.tmpl
cp update.json.tmpl update.json
rm update.json.tmpl

Copy link
Member Author

Choose a reason for hiding this comment

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

This modified version might work:

# update information in update.json using a temporarily file
jq '.addons["[email protected]"].updates[0].version = "${version}" updates.json | 
    .addons["[email protected]"].updates[0].update_link = "https://github.com/UB-Mannheim/zotero-ocr/releases/tag/${version}/zotero-ocr-${version}.xpi" | 
    .addons["[email protected]"].updates[0].update_hash = "sha256:$(shasum -a 256 build/zotero-ocr-${version}.xpi | cut -d\' \' -f1)"' > updates.json.tmp
cp updates.json.tmp updates.json
rm updates.json.tmp

It requires five commands instead of three, but does not require an additional template file.

Copy link
Member Author

Choose a reason for hiding this comment

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

jq could also be replaced by perl or sed which allow inline edits, so also can do the job without an additional template or temporary file. But that are cosmetic details without an effect on the resulting plug-in.

- uses: actions/upload-artifact@v4
with:
name: Zotero OCR plugin (zipped)
path: "*.xpi"
Copy link
Member

Choose a reason for hiding this comment

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

If we could do this without zipping the xpi file, that would be easier to handle.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but that's how GitHub handles artifacts. "There is currently no way to download artifacts in a format other than a Zip or to download individual artifact contents" (see https://github.com/actions/upload-artifact#zip-archives).

Copy link
Member Author

@stweil stweil Mar 26, 2024

Choose a reason for hiding this comment

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

We could upload the files which make up a xpi file. Then upload-artifacts would create a zip file, but that would not simplify the handling for users: they would have to rename the downloaded zip file to get an xpi file.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe I am wrong, but can't these action also handle an individual file upload? https://github.com/actions/upload-artifact?tab=readme-ov-file#upload-an-individual-file We just need to upload the xpi file which is an individual file.

Copy link
Member Author

Choose a reason for hiding this comment

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

De facto it is an individual file upload, because "*.xpi" is only a single file.

src/install.rdf Outdated
@@ -6,8 +6,7 @@
RDF:about="urn:mozilla:install-manifest"
em:id="[email protected]"
em:name="Zotero OCR"
em:version="0.6.0"
em:type="2"
em:version="1.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Below here in the install.rdf you need to increase the minVersion to 6.0 twice, as the json-style update works as far as we know from then on only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the hint. That's done now.

stweil added 6 commits March 26, 2024 16:08
- remove failing commands
- now allows version argument
- update files for Zotero 6 and Zotero 7
- create annotated tag for release

Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Stefan Weil <[email protected]>
@stweil
Copy link
Member Author

stweil commented Mar 26, 2024

I now replaced the jq commands by perl commands which no longer require updates.json.tmpl and changed the new version to 0.7.0.

stweil added 2 commits March 26, 2024 17:24
Signed-off-by: Stefan Weil <[email protected]>
@zuphilip zuphilip merged commit c1aa3eb into UB-Mannheim:master Mar 26, 2024
1 check passed
@zuphilip
Copy link
Member

🎉 Hooray 🎉 This is now merged. Thank you very much @stweil and @aborel for the work on this!

@stweil stweil deleted the z6+7 branch March 26, 2024 18:50
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.

3 participants