ruby: get link to bookmark

This commit is contained in:
Andrew
2020-05-21 14:39:10 +03:00
parent b3a79deef8
commit ecbae22fcc
3 changed files with 13 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class HomeController < ApplicationController
DocumentHelper.init(request.remote_ip, request.base_url)
@file = FileModel.new(:file_name => params[:fileName], :mode => params[:editorsMode], :type => params[:editorsType], :user_ip => request.remote_ip, :lang => cookies[:ulang], :uid => cookies[:uid], :uname => cookies[:uname])
@file = FileModel.new(:file_name => params[:fileName], :mode => params[:editorsMode], :type => params[:editorsType], :user_ip => request.remote_ip, :lang => cookies[:ulang], :uid => cookies[:uid], :uname => cookies[:uname], :action_data => params[:actionLink])
end

View File

@ -1,6 +1,6 @@
class FileModel
attr_accessor :file_name, :mode, :type, :user_ip, :lang, :uid, :uname
attr_accessor :file_name, :mode, :type, :user_ip, :lang, :uid, :uname, :action_data
def initialize(attributes = {})
@file_name = attributes[:file_name]
@ -10,6 +10,7 @@ class FileModel
@lang = attributes[:lang]
@user_id = attributes[:uid]
@user_name = attributes[:uname]
@action_data = attributes[:action_data]
end
def type
@ -70,6 +71,7 @@ class FileModel
}
},
:editorConfig => {
:actionLink => @action_data ? JSON.parse(@action_data) : nil,
:mode => mode,
:lang => @lang ? @lang : "en",
:callbackUrl => callback_url,

View File

@ -38,6 +38,13 @@
location.reload(true);
};
var onMakeActionLink = function (event) {
var actionData = event.data;
var linkParam = JSON.stringify(actionData);
var link = location.href + "&actionLink=" + encodeURIComponent(linkParam);
docEditor.setActionLink(link);
};
var сonnectEditor = function () {
var config = <%= raw @file.get_config.to_json %>;
@ -48,7 +55,8 @@
'onAppReady': onAppReady,
'onDocumentStateChange': onDocumentStateChange,
'onError': onError,
'onOutdatedVersion': onOutdatedVersion
'onOutdatedVersion': onOutdatedVersion,
'onMakeActionLink': onMakeActionLink,
};
<%