mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
c263f48b79
no issue - The `adminKey.secret` property is already in the correct format of `admiKey.Id:adminKey.secret` so we were returning the id twice as query param - Minor style adjustments for Explore
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class ExploreController extends Controller {
|
|
@service ghostPaths;
|
|
|
|
get apiUrl() {
|
|
const origin = new URL(window.location.origin);
|
|
const subdir = this.ghostPaths.subdir;
|
|
// We want the API URL without protocol
|
|
let url = this.ghostPaths.url.join(origin.host, subdir);
|
|
|
|
return url.replace(/\/$/, '');
|
|
}
|
|
|
|
get exploreCredentials() {
|
|
const explore = this.model.findBy('slug', 'ghost-explore');
|
|
const adminKey = explore.adminKey;
|
|
|
|
return adminKey.secret;
|
|
}
|
|
|
|
@action
|
|
submitExploreSite() {
|
|
const token = this.exploreCredentials;
|
|
const apiUrl = this.apiUrl;
|
|
|
|
// Ghost Explore URL to submit a new site
|
|
const destination = new URL('https://ghost.org/explore/submit');
|
|
const query = new URLSearchParams();
|
|
|
|
query.append('token', token);
|
|
query.append('url', apiUrl);
|
|
|
|
destination.search = query;
|
|
|
|
window.location = destination.toString();
|
|
}
|
|
}
|