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

从 xpi 包获取 id 和 description #49

Merged
merged 9 commits into from Nov 30, 2023
Merged

从 xpi 包获取 id 和 description #49

merged 9 commits into from Nov 30, 2023

Conversation

northword
Copy link
Member

@northword northword commented Nov 28, 2023

ref: #41

待办:补全 descriptioninstall.rdf 结构居然不一样,需要额外适配一下:

<?xml version="1.0"?>
<RDF:RDF
    xmlns:em="http://www.mozilla.org/2004/em-rdf#"
    xmlns:NC="http://home.netscape.com/NC-rdf#"
    xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <RDF:Description
        RDF:about="urn:mozilla:install-manifest"
        em:id="zotero-format-metadata@northword.cn"
        em:name="Zotero Format Metadata"
        em:version="0.4.4"
        em:type="2"
        em:creator="northword"
        em:description="An addon for Zotero to format item metadata"
        em:homepageURL="https://github.com/northword/zotero-format-metadata#readme"
        em:iconURL="chrome://formatmetadata/content/icons/favicon.png"
        em:optionsURL="chrome://formatmetadata/content/preferences.xul"
        em:updateURL="https://github.com/northword/zotero-format-metadata/releases/latest/download/update.json"
        em:multiprocessCompatible="true"
        em:bootstrap="true">
        <em:targetApplication>
            <Description>
                <em:id>zotero@chnm.gmu.edu</em:id>
                <em:minVersion>5.0</em:minVersion>
                <em:maxVersion>*</em:maxVersion>
            </Description>
        </em:targetApplication>
        <em:targetApplication>
            <Description>
                <em:id>juris-m@juris-m.github.io</em:id>
                <em:minVersion>5.0</em:minVersion>
                <em:maxVersion>*</em:maxVersion>
            </Description>
        </em:targetApplication>
  </RDF:Description>
</RDF:RDF>
<?xml version="1.0" encoding="utf-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">

    <Description about="urn:mozilla:install-manifest">
        <em:id>keepzotero@yhmtsai</em:id>
        <em:name>KeepZotero</em:name>
        <em:version>0.0.2</em:version>
        <em:type>2</em:type>
        <em:multiprocessCompatible>true</em:multiprocessCompatible>
        <em:optionsURL>chrome://keepzotero/content/options.xul</em:optionsURL>
        <em:updateURL>https://raw.githubusercontent.com/yhmtsai/KeepZotero/master/keepzotero-update.rdf</em:updateURL>
        <em:creator>Yu-Hsiang Mike Tsai</em:creator>

        <em:targetApplication>
            <Description>
                <em:id>zotero@chnm.gmu.edu</em:id>
                <em:minVersion>5.0.0</em:minVersion>
                <em:maxVersion>6.0.*</em:maxVersion>
            </Description>
        </em:targetApplication>
        <em:localized>
            <Description>
                <em:locale>en-US</em:locale>
                <em:name>KeepZotero</em:name>
                <em:description>Keep Zotero in Taskbar</em:description>
            </Description>
        </em:localized>
    </Description>
</RDF>

奇怪的 rdf 再加一:(em:id

<?xml version="1.0"?>
<RDF:RDF
    xmlns:em="http://www.mozilla.org/2004/em-rdf#"
    xmlns:NC="http://home.netscape.com/NC-rdf#"
    xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <RDF:Description
        RDF:about="rdf:#$x61SL3"
        em:id="{7B7BE31E-0C0F-436B-8A26-4C199B543C9E}"
        em:minVersion="2.0"
        em:maxVersion="20.*"/>
    <RDF:Description
        RDF:about="urn:mozilla:install-manifest"
        em:id="zoterozotcard@018.ai"
        em:name="ZotCard"
        em:version="2.8.1"
        em:type="2"
        em:iconURL="chrome://zoterozotcard/skin/zotcard.png"
        em:icon64URL="chrome://zoterozotcard/skin/zotcard64.png"
        em:creator="018"
        em:description="写卡更柔顺,读卡更顺滑。"
        em:homepageURL="https://github.com/018/zotcard"
        em:updateURL="https://raw.githubusercontent.com/018/zotcard/main/update.rdf">
        <em:type>2</em:type>
        <em:targetApplication RDF:resource="rdf:#$x61SL3"/>
        <em:targetApplication>
            <Description>
                <em:id>zotero@chnm.gmu.edu</em:id>
                <em:minVersion>5.0.66</em:minVersion>
                <em:maxVersion>*</em:maxVersion>
            </Description>
        </em:targetApplication>
    </RDF:Description>
</RDF:RDF>

@syt2
Copy link
Contributor

syt2 commented Nov 29, 2023

可能对于zotcard的也需要特地适配下

可供参考的信息
firefox XPIInstall
firefox addon.py
addon-scraper

另外,是否需要考虑对于同时存在z6、z7的插件,开发者使用了不同的id的极端情况?(目前未遇到)

无法正确获取到极个别插件id
@northword
Copy link
Member Author

另外,是否需要考虑对于同时存在z6、z7的插件,开发者使用了不同的id的极端情况?(目前未遇到)

严格的来说,id 变更就意味着已经是两个插件了,所以我觉得可以不用考虑?(主要是现在也没遇到)(我的想法是以从7里面获取到的为主)

@syt2
Copy link
Contributor

syt2 commented Nov 29, 2023

另外,是否需要考虑对于同时存在z6、z7的插件,开发者使用了不同的id的极端情况?(目前未遇到)

严格的来说,id 变更就意味着已经是两个插件了,所以我觉得可以不用考虑?(主要是现在也没遇到)(我的想法是以从7里面获取到的为主)

考虑了下也行,如果真遇到了,在plugins内把对应插件拆成两个就行。

@northword
Copy link
Member Author

另外,是否需要考虑对于同时存在z6、z7的插件,开发者使用了不同的id的极端情况?(目前未遇到)

严格的来说,id 变更就意味着已经是两个插件了,所以我觉得可以不用考虑?(主要是现在也没遇到)(我的想法是以从7里面获取到的为主)

考虑了下也行,如果真遇到了,在plugins内把对应插件拆成两个就行。

或者就是,id 不放 PluginInfo.id ,而是 PluginInfo.ReleaseInfo.id ?

@syt2
Copy link
Contributor

syt2 commented Nov 29, 2023

另外,是否需要考虑对于同时存在z6、z7的插件,开发者使用了不同的id的极端情况?(目前未遇到)

严格的来说,id 变更就意味着已经是两个插件了,所以我觉得可以不用考虑?(主要是现在也没遇到)(我的想法是以从7里面获取到的为主)

考虑了下也行,如果真遇到了,在plugins内把对应插件拆成两个就行。

或者就是,id 不放 PluginInfo.id ,而是 PluginInfo.ReleaseInfo.id ?

两种方案都可行吧。
我在zotero-addons-scraper里暂时两个都放了,等着这个仓库的格式同步修改脚本和插件去👀

@northword

This comment was marked as outdated.

@northword northword marked this pull request as ready for review November 29, 2023 07:14
@northword northword marked this pull request as draft November 29, 2023 07:26
@northword
Copy link
Member Author

northword commented Nov 29, 2023

下面是没有考虑不同版本 id 不同的,感觉应该是和 zotero-addons-scraper 比较接近的,你看下需不需要修改呢?

优先从 manifest.json 中获取,如果不存在这个文件,才从 install.rdf 获取。

另外为了节省传输的体积, plugins.json取消了缩进,大约从 71kb -> 58kb。

[
  {
    "name": "Zotero Format Metadata",
    "repo": "northword/zotero-format-metadata",
    "releases": [
      {
        "targetZoteroVersion": "7",
        "tagName": "latest",
        "currentVersion": "1.6.11",
        "assetId": 135864033,
        "releaseData": "2023-11-16T14:35:35Z",
        "downloadCount": 2250,
        "xpiDownloadUrl": {
          "github": "https://github.com/northword/zotero-format-metadata/releases/download/1.6.11/zotero-format-metadata.xpi",
          "gitee": "https://gitee.com/northword/zotero-plugins/raw/gh-pages/dist/xpi/135864033.xpi",
          "ghProxy": "https://ghproxy.com/?q=https://github.com/northword/zotero-format-metadata/releases/download/1.6.11/zotero-format-metadata.xpi",
          "jsdeliver": "https://cdn.jsdelivr.net/gh/northword/zotero-plugins@gh-pages/dist/xpi/135864033.xpi",
          "kgithub": "https://kkgithub.com/northword/zotero-format-metadata/releases/download/1.6.11/zotero-format-metadata.xpi"
        }
      },
      {
        "targetZoteroVersion": "6",
        "tagName": "0.4.4",
        "currentVersion": "0.4.4",
        "assetId": 112232528,
        "releaseData": "2023-06-11T06:51:01Z",
        "downloadCount": 12669,
        "xpiDownloadUrl": {
          "github": "https://github.com/northword/zotero-format-metadata/releases/download/0.4.4/zotero-format-metadata.xpi",
          "gitee": "https://gitee.com/northword/zotero-plugins/raw/gh-pages/dist/xpi/112232528.xpi",
          "ghProxy": "https://ghproxy.com/?q=https://github.com/northword/zotero-format-metadata/releases/download/0.4.4/zotero-format-metadata.xpi",
          "jsdeliver": "https://cdn.jsdelivr.net/gh/northword/zotero-plugins@gh-pages/dist/xpi/112232528.xpi",
          "kgithub": "https://kkgithub.com/northword/zotero-format-metadata/releases/download/0.4.4/zotero-format-metadata.xpi"
        }
      }
    ],
    "description": "Linter for Zotero. An addon for Zotero to format item metadata. Shortcut to set rich text, set journal abbreviations, university places, item languages, etc.",
    "star": 164,
    "watchers": 164,
    "author": {
      "name": "Northword",
      "url": "https://northword.dev",
      "avatar": "https://avatars.githubusercontent.com/u/44738481?v=4"
    },
    "id": "zotero-format-metadata@northword.cn"
  },
  {
    "name": "Chartero",
    "repo": "volatile-static/Chartero",
    "releases": [
      {
        "targetZoteroVersion": "6",
        "tagName": "latest",
        "currentVersion": "2.2.0",
        "assetId": 137018637,
        "releaseData": "2023-11-23T05:28:49Z",
        "downloadCount": 1278,
        "xpiDownloadUrl": {
          "github": "https://github.com/volatile-static/Chartero/releases/download/2.2.0/chartero.xpi",
          "gitee": "https://gitee.com/northword/zotero-plugins/raw/gh-pages/dist/xpi/137018637.xpi",
          "ghProxy": "https://ghproxy.com/?q=https://github.com/volatile-static/Chartero/releases/download/2.2.0/chartero.xpi",
          "jsdeliver": "https://cdn.jsdelivr.net/gh/northword/zotero-plugins@gh-pages/dist/xpi/137018637.xpi",
          "kgithub": "https://kkgithub.com/volatile-static/Chartero/releases/download/2.2.0/chartero.xpi"
        }
      }
    ],
    "description": "Chart in Zotero",
    "star": 233,
    "watchers": 233,
    "author": {
      "name": "volatile-static",
      "url": "https://github.com/volatile-static",
      "avatar": "https://avatars.githubusercontent.com/u/59945270?v=4"
    },
    "id": "chartero@volatile.static"
  }
]

@northword northword marked this pull request as ready for review November 29, 2023 07:56
@syt2
Copy link
Contributor

syt2 commented Nov 29, 2023

get,没问题

@northword
Copy link
Member Author

CC @volatile-static , 这个 PR 里变更了 ts-node,也许你要看下你那边能不能正常运行(我觉得是没啥问题的)

src/get_plugins_info.ts Outdated Show resolved Hide resolved
@volatile-static
Copy link
Contributor

CC @volatile-static , 这个 PR 里变更了 ts-node,也许你要看下你那边能不能正常运行(我觉得是没啥问题的)

我暂时不需要本地跑了。你那边测着正常就ok

@northword northword merged commit 8c4ded4 into main Nov 30, 2023
@northword northword deleted the add-id branch November 30, 2023 00:55
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.

None yet

3 participants