DBLSQD Web Integration
Integrating information from a DBLSQD Feed into any website is possible with intelligent download links and our JavaScript Web Integration module.
Intelligent Download Links
DBLSQD offers intelligent download links to make integrating downloads into static websites as easy as possible. The following is all you need in order to add a DBLSQD-powered download link to your site:
<a href="https://feeds.dblsqd.com/:app_token/:channel/:os/:arch/dl/:version">
Download My Application!
</a>
Now what makes these links “intelligent”? You don’t have to specify a full
:version in the URL. Instead, you can either use
latest
or a partial version number like
1.0
. When using a partial version
number, DBLSQD will automatically redirect to the latest compatible version.
Example
Let’s say we have an application with the following Releases:
1.1.0
,
1.1.1
,
1.2.0
, and
2.0.0
Here are some intelligent download links we could use:
"https://feeds.dblsqd.com/:app_token/:channel/:os/:arch/dl/latest"
// => redirects to 2.0.0
"https://feeds.dblsqd.com/:app_token/:channel/:os/:arch/dl/1.1"
// => redirects to 1.1.1
"https://feeds.dblsqd.com/:app_token/:channel/:os/:arch/dl/1"
// => redirects to 1.2.0
DBLSQD JavaScript Web Integration
The easiest way to add information from a DBLSQD Feed to your website is our JavaScript libary dblsqd-web.
Using the CDN
You can directly add a script tag to your site that loads dblsqd-web from the unpkg CDN:
<script src="https://unpkg.com/dblsqd-web@0/dist/dblsqd-web.min.js"></script>
Using Browserify, Webpack, et. al.
If you’re using browserify
or a
similar tool, you can also install dblsqd-web with npm
(npm install --save dblsqd-web
)
and then require it in your code:
const dblsqdWeb = require("dblsqd-web")
Compatibility
All common browsers starting with IE9 are supported by dblsqd-web.
Loading Feed information
dblsqd-web has a simple Promise-based API for loading Feed data:
dblsqdWeb.loadFeed(app_token, channel, os, arch, type, opts)
- app_token - App token. See also: Getting Started Guide: Feeds
- channel - Channel
- os - Operating system
- arch - Processor architecture
- [type] - Artifact type
-
[opts]
- endpoint=https://feeds.dblsqd.com – Feeds endpoint. Defautlts to feeds.dblsqd.com.
dblsqdWeb.loadFeed(":app_token", ":channel", ":os", ":arch").then(function(feed) {
//feed is an object of the JSON Feed.
})
Inserting a Changelog
dblsqdWeb.insertChangelog
inserts the changelog for a given Feed into a DOM element.
dblsqdWeb.insertChangelog(element, feed, opts)
- element - Selector string or HTMLElement
- feed - Feed object retrieved with loadFeed
-
[opts]
- paragraphHighlight=false – Highlights a portion of every paragraph by wrapping it in a <strong> tag.
- paragraphHighlightExp=/([^:]*:)?(.*$)/ - The RegExp to determine which part of the paragraph should be highlighted. The RegExp must have two capture groups. The contents of the first group will be highlighted.
Changelog Placeholder
It is possible to insert a placeholder as shown in the demo underneath with
dblsqdWeb.insertChangelogPlaceholder(element)
.
This is usually not necessary since the response from the DBLSQD Feed server
is almost instantaneous most of the time.
Example
dblsqd.insertChangelogPlaceholder("#changelog-container")
dblsqd.loadFeed(":app_token", "release", "win", "x86_64").then(function(feed) {
dblsqdWeb.insertChangelog("#changelog-container", feed, {paragraphHighlight: true})
})
Inserting the Latest Version Number
dblsqdWeb.insertLatestVersion
inserts the version number of the latest Release in a given Feed into a DOM
element.
dblsqdWeb.insertLatestVersion(element, feed)
- element - Selector string or HTMLElement
- feed - Feed object retrieved with loadFeed
Example
dblsqdWeb.loadFeed(":app_token", "release", "win", "x86_64").then(function(feed) {
dblsqdWeb.insertLatestVersion("#download-button .version-number", feed)
})
Retrieving download information
Here are some convenience functions for retrieving information from a Feed:
dblsqdWeb.getLatestVersion(feed)
Returns the version number of the latest Release
- feed - Feed object retrieved with loadFeed
dblsqdWeb.getDownloadUrl(feed)
Returns the direct download URL for a Release from the given Feed.
- feed - Feed object retrieved with loadFeed
- [version] - Release version. Defaults to latest version if not provided.
dblsqdWeb.getDownloadSha256(feed)
Returns the SHA256 hash of the download for a Release from the given Feed.
- feed - Feed object retrieved with loadFeed
- [version] - Release version. Defaults to latest version if not provided.
dblsqdWeb.getDownloadSize(feed)
Returns the file size in bytes of the download for a Release from the given Feed.
- feed - Feed object retrieved with loadFeed
- [version] - Release version. Defaults to latest version if not provided.