mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Compare commits
1 Commits
v2.9.17
...
feature/ne
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0887429665 |
@@ -50,6 +50,7 @@ export default class ModalPermalink extends TranslatedComponent {
|
|||||||
<h3 >{translate('shortened')}</h3>
|
<h3 >{translate('shortened')}</h3>
|
||||||
<input value={this.state.shortenedUrl} readOnly size={25} onFocus={ (e) => e.target.select() }/>
|
<input value={this.state.shortenedUrl} readOnly size={25} onFocus={ (e) => e.target.select() }/>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
<p>s.orbis.zone is the new URL shortener domain, old eddp.co urls are considered end of life and could go down at any moment. Sorry for any inconvenience.</p>
|
||||||
<button className={'r dismiss cap'} onClick={this.context.hideModal}>{translate('close')}</button>
|
<button className={'r dismiss cap'} onClick={this.context.hideModal}>{translate('close')}</button>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import request from 'superagent';
|
|||||||
* @param {function} error Failure/Error callback
|
* @param {function} error Failure/Error callback
|
||||||
*/
|
*/
|
||||||
export default function shorternUrl(url, success, error) {
|
export default function shorternUrl(url, success, error) {
|
||||||
shortenUrlEddp(url, success, error);
|
shortenUrlOrbis(url, success, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SHORTEN_API_GOOGLE = 'https://www.googleapis.com/urlshortener/v1/url?key=';
|
const SHORTEN_API_GOOGLE = 'https://www.googleapis.com/urlshortener/v1/url?key=';
|
||||||
@@ -64,3 +64,32 @@ function shortenUrlEddp(url, success, error) {
|
|||||||
error('Not Online');
|
error('Not Online');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SHORTEN_API_ORBIS = 'https://s.orbis.zone/a';
|
||||||
|
/**
|
||||||
|
* Shorten a URL using Orbis's URL shortener API
|
||||||
|
* @param {string} url The URL to shorten
|
||||||
|
* @param {function} success Success callback
|
||||||
|
* @param {function} error Failure/Error callback
|
||||||
|
*/
|
||||||
|
function shortenUrlOrbis(url, success, error) {
|
||||||
|
if (window.navigator.onLine) {
|
||||||
|
try {
|
||||||
|
request.post(SHORTEN_API_ORBIS)
|
||||||
|
.field('lsturl', url)
|
||||||
|
.field('format', 'json')
|
||||||
|
.end(function(err, response) {
|
||||||
|
if (err) {
|
||||||
|
error('Bad Request');
|
||||||
|
} else {
|
||||||
|
success(response.body.short);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
error(e.message ? e.message : e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error('Not Online');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user