FEATURE: allow themes to live in private git repos

This feature allows themes sourced from git to live on private
servers, it automatically generates key pairs.
This commit is contained in:
Sam
2018-03-09 16:14:21 +11:00
parent 200c6673f1
commit 39e679d3cb
13 changed files with 145 additions and 10 deletions

View File

@ -27,6 +27,16 @@ class Admin::ThemesController < Admin::AdminController
end
end
def generate_key_pair
require 'sshkey'
k = SSHKey.generate
render json: {
private_key: k.private_key,
public_key: k.ssh_public_key
}
end
def import
@theme = nil
if params[:theme]
@ -66,8 +76,12 @@ class Admin::ThemesController < Admin::AdminController
render json: @theme.errors, status: :unprocessable_entity
end
elsif params[:remote]
@theme = RemoteTheme.import_theme(params[:remote])
render json: @theme, status: :created
begin
@theme = RemoteTheme.import_theme(params[:remote], current_user, private_key: params[:private_key])
render json: @theme, status: :created
rescue RuntimeError
render_json_error I18n.t('errors.theme.other')
end
else
render json: @theme.errors, status: :unprocessable_entity
end