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

badge to show downloads count from jetbrains plugin repository #896

Closed
wants to merge 3 commits into from

Conversation

mskonovalov
Copy link

@mskonovalov mskonovalov commented Mar 23, 2017

Add badge with dynamic retrieve download counts of Jetbrains plugins from https://plugins.jetbrains.com/
#895
Xml API is used.
You need to provide Xml Id of plugin to get its data

@paulmelnikow paulmelnikow added the service-badge New or updated service badge label Mar 27, 2017

request(url, function(err, res, buffer) {
if (err) {
badgeData.text[1] = 'inaccessible';
Copy link
Member

Choose a reason for hiding this comment

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

You can handle status code 404 here, this will give users better feedback:

if (res.statusCode === 404) {
    badgeData.text[1] = 'plugin not found';
} else {
    badgeData.text[1] = 'inaccessible';
}

Copy link
Author

Choose a reason for hiding this comment

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

Good idea, thank you

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, XML API does not return 404 when plugin is not found. Sorry, I didn't check this before.

> curl "https://plugins.jetbrains.com/plugins/list?pluginId=PLUGIN_NOT_FOUND"      
<?xml version="1.0" encoding="UTF-8"?><plugin-repository></plugin-repository>

Copy link
Author

Choose a reason for hiding this comment

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

It's ok, I've just made fix for this

@mskonovalov
Copy link
Author

As their xml API doesn't support 404 code for wrong plugin id needed to add a bit more complex check

@mskonovalov mskonovalov force-pushed the jetbrains-plugin-badge branch from 8954599 to 3baddb1 Compare March 30, 2017 10:25
@mskonovalov
Copy link
Author

Guys something went wrong as most pull requests start to fail on travis

@paulmelnikow
Copy link
Member

@mskonovalov Fixed in 522e09f.

@mskonovalov mskonovalov reopened this Mar 31, 2017
@mskonovalov
Copy link
Author

Closed and reopened to trigger rebuild

@platan
Copy link
Member

platan commented Apr 26, 2017

I would like to use this badge. Can I somehow help with this PR?

@mskonovalov
Copy link
Author

Same for me.
Have no idea how to speed up the process

@paulmelnikow
Copy link
Member

Hi, thanks for this contribution. Sorry for the delay. As you can see there is a large backlog, which we're slowly working through. This looks good. I will leave a couple comments.

<tr><th data-keywords='jetbrains plugin'> Jetbrains plugins: </th>
<td><img src='https://img.shields.io/jetbrainsplugins/org.intellij.scala/d.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/jetbrainsplugins/PLUGIN_XML_ID/d.svg</code></td>
</tr>
Copy link
Member

Choose a reason for hiding this comment

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

index.html has been removed in master. Could you merge master into this branch and remove it here too?

@@ -5769,6 +5769,49 @@ cache(function(data, match, sendBadge, request) {
});
}));

// Jetbrains Plugins repository integration
camp.route(/^\/jetbrainsplugins\/([^\/]+)\/(d)\.(svg|png|gif|jpg|json)$/,
Copy link
Member

Choose a reason for hiding this comment

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

Could I ask you to make the URI consistent with https://img.shields.io/wordpress/plugin/v/akismet.svg?

i.e. /jetbrains/plugin/d/name.of.plugin.svg

@paulmelnikow
Copy link
Member

@paulmelnikow
Copy link
Member

Let's continue this in #1025.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants