diff --git a/app/assets/javascripts/widgets/submitter.js.erb b/app/assets/javascripts/widgets/submitter.js.erb index bd3dd3c90..b6f90b5ac 100644 --- a/app/assets/javascripts/widgets/submitter.js.erb +++ b/app/assets/javascripts/widgets/submitter.js.erb @@ -28,10 +28,15 @@ var LumenSubmitterWidget = (function () { if (this.dom_element) { this.iframe = document.createElement('iframe'); this.iframe.src = this.SERVICE_URL; + this.iframe.style.cssText = 'border: none; margin: 0; padding: 0; width:100%;'; this.dom_element.appendChild(this.iframe); // This will max the iframe size - iFrameResize({ log: false }, this.iframe) + iFrameResize({ + log: false, + warningTimeout: 0, + checkOrigin: false + }, this.iframe) } } }; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 83f3d727f..c26104bbb 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -34,7 +34,6 @@ @import 'layouts/application'; @import 'layouts/home'; @import 'layouts/sessions'; -@import 'layouts/submitter_widget'; // Views @import 'home/index'; diff --git a/app/assets/stylesheets/layouts/_submitter_widget.scss b/app/assets/stylesheets/submitter_widget.css.scss similarity index 97% rename from app/assets/stylesheets/layouts/_submitter_widget.scss rename to app/assets/stylesheets/submitter_widget.css.scss index 6b9d9cdb5..39defda70 100644 --- a/app/assets/stylesheets/layouts/_submitter_widget.scss +++ b/app/assets/stylesheets/submitter_widget.css.scss @@ -1,6 +1,7 @@ .submitter_widget_notices { /* @HACK:FIXME Firefox has problems with rendering an iframe */ width: calc(100% - 1px); + background-color: #ffffff; section.main.app { background-color: #ffffff; diff --git a/app/controllers/submitter_widget_notices_controller.rb b/app/controllers/submitter_widget_notices_controller.rb index 4ef44fd34..9dd3616a0 100644 --- a/app/controllers/submitter_widget_notices_controller.rb +++ b/app/controllers/submitter_widget_notices_controller.rb @@ -27,12 +27,13 @@ def create end @notice = NoticeBuilder.new( - get_notice_type(params), notice_params, current_user + get_notice_type(params), notice_params, submitter_widget_user ).build + @notice.review_required = true + if @notice.valid? @notice.save - @notice.mark_for_review flash.notice = 'Notice created! Thank you, it will be reviewed and published on the Lumen database website.' else Rails.logger.warn "Could not create notice with params: #{params}" @@ -46,7 +47,7 @@ def create def build_entity_notice_roles(model_class) model_class::DEFAULT_ENTITY_NOTICE_ROLES.each do |role| - next if %w[sender recipient].include?(role) + next if %w[submitter recipient].include?(role) @notice.entity_notice_roles.build(name: role).build_entity( kind: default_kind_based_on_role(role) @@ -55,8 +56,7 @@ def build_entity_notice_roles(model_class) end def allowed_to_submit? - widget_public_key && - User.find_by_widget_public_key(widget_public_key.to_s) + widget_public_key && submitter_widget_user end def authorized_to_create? @@ -70,6 +70,10 @@ def widget_public_key end def redirect_to_new_form - redirect_to new_submitter_widget_notice_path(type: params[:notice][:type], widget_public_key: @widget_public_key) + redirect_to new_submitter_widget_notice_path(widget_public_key: @widget_public_key) + end + + def submitter_widget_user + User.find_by_widget_public_key(widget_public_key.to_s) end end diff --git a/app/views/layouts/submitter_widget.html.erb b/app/views/layouts/submitter_widget.html.erb index 62bf8bb9e..c78f4096b 100644 --- a/app/views/layouts/submitter_widget.html.erb +++ b/app/views/layouts/submitter_widget.html.erb @@ -5,7 +5,17 @@ <%= yield(:title) %> <%= render 'shared/head' -%> - <%= stylesheet_link_tag 'submitter_widget', :media => 'all' %> + <%= stylesheet_link_tag :submitter_widget, :media => 'all' %> + <%= render 'flashes' -%> diff --git a/app/views/mailers/api_submitter_request_approved.text.erb b/app/views/mailers/api_submitter_request_approved.text.erb index 1e5635afc..4816e9296 100644 --- a/app/views/mailers/api_submitter_request_approved.text.erb +++ b/app/views/mailers/api_submitter_request_approved.text.erb @@ -2,9 +2,9 @@ Hi, your submitter plugin access request has been approved. -Your plugin private key is: <%= @user.authentication_token %> +Your plugin private key is: <%= @user.widget_public_key %> -You can use it to configure the plugin. Integration documentation of the plugin is located here: <%= root_url %>/api_submitter_documentation. +You can use it to configure the plugin. Integration documentation of the plugin is located here: <%= Chill::Application.config.site_host %>/api_submitter_documentation. Thank you, Lumen Database team diff --git a/app/views/notices/new.html.erb b/app/views/notices/new.html.erb index 8d39df221..9925eb9af 100644 --- a/app/views/notices/new.html.erb +++ b/app/views/notices/new.html.erb @@ -3,5 +3,3 @@
<%= render form_partial_for(@notice), notice: @notice %>
- -<%= javascript_include_tag('iframe-resizer-server.min') %> diff --git a/app/views/notices/select_type.html.erb b/app/views/notices/select_type.html.erb index 1d97f540f..7e3cb3f7d 100644 --- a/app/views/notices/select_type.html.erb +++ b/app/views/notices/select_type.html.erb @@ -33,5 +33,3 @@ <% end %> - -<%= javascript_include_tag('iframe-resizer-server.min') %> diff --git a/app/views/notices/submitter_widget/new.html.erb b/app/views/notices/submitter_widget/new.html.erb index 8d39df221..6f7e2f754 100644 --- a/app/views/notices/submitter_widget/new.html.erb +++ b/app/views/notices/submitter_widget/new.html.erb @@ -5,3 +5,11 @@ <%= javascript_include_tag('iframe-resizer-server.min') %> +<%= javascript_include_tag('pace.min') %> +<%= stylesheet_link_tag('pace', :media => 'all') %> + + diff --git a/app/views/notices/submitter_widget/select_type.html.erb b/app/views/notices/submitter_widget/select_type.html.erb index 4ed754a16..1ac8f8b76 100644 --- a/app/views/notices/submitter_widget/select_type.html.erb +++ b/app/views/notices/submitter_widget/select_type.html.erb @@ -33,3 +33,5 @@ <%= javascript_include_tag('iframe-resizer-server.min') %> +<%= javascript_include_tag('pace.min') %> +<%= stylesheet_link_tag('pace', :media => 'all') %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 388379c2d..5ee89f62a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -13,4 +13,11 @@ # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) Rails.application.config.assets.non_digest_named_assets = ['widgets/*.js'] -Rails.application.config.assets.precompile += %w[widgets/submitter.js iframe-resizer-server.min iframe-resizer-client.min] +Rails.application.config.assets.precompile += %w[ + widgets/submitter.js + iframe-resizer-server.min + iframe-resizer-client.min + submitter_widget.css + pace.min.js + pace.css +] diff --git a/vendor/assets/javascripts/pace.min.js b/vendor/assets/javascripts/pace.min.js new file mode 100644 index 000000000..b82e25713 --- /dev/null +++ b/vendor/assets/javascripts/pace.min.js @@ -0,0 +1,6 @@ +/*! + * pace.js v1.2.4 + * https://github.com/CodeByZach/pace/ + * Licensed MIT © HubSpot, Inc. + */ +!function(){function o(t,e){return function(){return t.apply(e,arguments)}}var u,c,i,s,n,y,t,l,v,r,a,p,e,h,w,b,f,g,d,m,k,S,q,L,x,P,T,R,j,O,E,M,A,C,N,_,F,U,W,X,D,H,I,z,G,B,J=[].slice,K={}.hasOwnProperty,Q=function(t,e){for(var n in e)K.call(e,n)&&(t[n]=e[n]);function r(){this.constructor=t}return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},V=[].indexOf||function(t){for(var e=0,n=this.length;e\n
\n\n
',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},$.prototype.finish=function(){var t=this.getElement();return t.className=t.className.replace("pace-active","pace-inactive"),document.body.className=document.body.className.replace("pace-running ","pace-done ")},$.prototype.update=function(t){return this.progress=t,y.trigger("progress",t),this.render()},$.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(t){n=t}return this.el=void 0},$.prototype.render=function(){var t,e,n,r,s,o,i;if(null==document.querySelector(T.target))return!1;for(t=this.getElement(),r="translate3d("+this.progress+"%, 0, 0)",s=0,o=(i=["webkitTransform","msTransform","transform"]).length;sT.eventLag.sampleCount&&o.shift(),e=h(o),++s>=T.eventLag.minSamples&&ethis.progress&&(this.progress+=this.catchup*t),e=1-Math.pow(this.progress/100,T.easeFactor),this.progress+=e*this.rate*t,this.progress=Math.min(this.lastProgress+T.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},v=it,b=e=_=w=E=N=null,y.running=!1,q=function(){if(T.restartOnPushState)return y.restart()},null!=window.history.pushState&&(I=window.history.pushState,window.history.pushState=function(){return q(),I.apply(window.history,arguments)}),null!=window.history.replaceState&&(G=window.history.replaceState,window.history.replaceState=function(){return q(),G.apply(window.history,arguments)}),l={ajax:u,elements:k,document:B,eventLag:Q},(x=function(){var t,e,n,r,s,o,i,a;for(y.sources=N=[],e=0,r=(o=["ajax","elements","document","eventLag"]).length;e