oovm / ZhihuLink

A Mathematica package used to download Q&As on zhihu.com
Mozilla Public License 2.0
8 stars 2 forks source link

Ways of install & update #8

Open oovm opened 6 years ago

oovm commented 6 years ago
oovm commented 6 years ago

Let's imagine a potential user.

What kind of installation does he want?


First, he/she'll the readme first.

So put a install-script on that?


Well, I don't want to update readme frequently, I mean , I may forget update the script.

An alternative way, put a link to the true install-script.


So the install.m undertake all tasks, install/check and update.

oovm commented 6 years ago

What should be included in the script?

Ok, first check the vision.

Then catch the latest release

Last, download and install the plugin.


Github API seems a nice way to get the vision.

get=HTTPRequest["https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/latest"];

Let's make a Get Request

{
  "url": "https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/10034384",
  "assets_url": "https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/10034384/assets",
  "upload_url": "https://uploads.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/10034384/assets{?name,label}",
  "html_url": "https://github.com/wjxway/ZhihuLink-Mathematica/releases/tag/pre",
  "id": 10034384,
  "tag_name": "pre",
  "target_commitish": "dev",
  "name": "Test vers",
  "draft": false,
  "author": {
    "login": "GalAster",
    "id": 17541209,
    "avatar_url": "https://avatars2.githubusercontent.com/u/17541209?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/GalAster",
    "html_url": "https://github.com/GalAster",
    "followers_url": "https://api.github.com/users/GalAster/followers",
    "following_url": "https://api.github.com/users/GalAster/following{/other_user}",
    "gists_url": "https://api.github.com/users/GalAster/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/GalAster/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/GalAster/subscriptions",
    "organizations_url": "https://api.github.com/users/GalAster/orgs",
    "repos_url": "https://api.github.com/users/GalAster/repos",
    "events_url": "https://api.github.com/users/GalAster/events{/privacy}",
    "received_events_url": "https://api.github.com/users/GalAster/received_events",
    "type": "User",
    "site_admin": false
  },
  "prerelease": false,
  "created_at": "2018-03-11T16:22:51Z",
  "published_at": "2018-03-11T16:25:20Z",
  "assets": [
    {
      "url": "https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/assets/6475750",
      "id": 6475750,
      "name": "ZhihuLink-0.0.6.paclet",
      "label": null,
      "uploader": {
        "login": "GalAster",
        "id": 17541209,
        "avatar_url": "https://avatars2.githubusercontent.com/u/17541209?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/GalAster",
        "html_url": "https://github.com/GalAster",
        "followers_url": "https://api.github.com/users/GalAster/followers",
        "following_url": "https://api.github.com/users/GalAster/following{/other_user}",
        "gists_url": "https://api.github.com/users/GalAster/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/GalAster/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/GalAster/subscriptions",
        "organizations_url": "https://api.github.com/users/GalAster/orgs",
        "repos_url": "https://api.github.com/users/GalAster/repos",
        "events_url": "https://api.github.com/users/GalAster/events{/privacy}",
        "received_events_url": "https://api.github.com/users/GalAster/received_events",
        "type": "User",
        "site_admin": false
      },
      "content_type": "application/octet-stream",
      "state": "uploaded",
      "size": 40363,
      "download_count": 1,
      "created_at": "2018-03-11T16:25:11Z",
      "updated_at": "2018-03-11T16:25:14Z",
      "browser_download_url": "https://github.com/wjxway/ZhihuLink-Mathematica/releases/download/pre/ZhihuLink-0.0.6.paclet"
    }
  ],
  "tarball_url": "https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/tarball/pre",
  "zipball_url": "https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/zipball/pre",
  "body": ""
}
oovm commented 6 years ago

We need url and add assets.

url=api["upload_url"]
assets=api["assets"]//First//Dataset
"url"->"https://api.github.com/repos/wjxway/ZhihuLink-Mathematica/releases/assets/6475750"
"id"->6475750
"name"->"ZhihuLink-0.0.6.paclet"
"label"->Null
"uploader"->{"login"->"GalAster","id"->17541209,"avatar_url"->"https://avatars2.githubusercontent.com/u/17541209?v=4","gravatar_id"->"","url"->"https://api.github.com/users/GalAster","html_url"->"https://github.com/GalAster","followers_url"->"https://api.github.com/users/GalAster/followers","following_url"->"https://api.github.com/users/GalAster/following{/other_user}","gists_url"->"https://api.github.com/users/GalAster/gists{/gist_id}","starred_url"->"https://api.github.com/users/GalAster/starred{/owner}{/repo}","subscriptions_url"->"https://api.github.com/users/GalAster/subscriptions","organizations_url"->"https://api.github.com/users/GalAster/orgs","repos_url"->"https://api.github.com/users/GalAster/repos","events_url"->"https://api.github.com/users/GalAster/events{/privacy}","received_events_url"->"https://api.github.com/users/GalAster/received_events","type"->"User","site_admin"->False}
"content_type"->"application/octet-stream"
"state"->"uploaded"
"size"->40363
"download_count"->1
"created_at"->"2018-03-11T16:25:11Z"
"updated_at"->"2018-03-11T16:25:14Z"
"browser_download_url"->"https://github.com/wjxway/ZhihuLink-Mathematica/releases/download/pre/ZhihuLink-0.0.6.paclet"

Emmmmm, I found a nice way sort just catch the browser_download_url.

There should be only one, but, if mult just sort.