Custom Layouts Plugin


(xiasummer) #62

Hi, I’m wondering how to add such things in as the right banner.

  1. A calendar, better to have Schedule Function.

  2. An Editable Advertisement Place for showing the sponsor’s logos.

Can that be done?


(Tobias) #63

Did someone make a list with widgets(plugins) created for this awesome plugin?


(Pad Pors) #64

all widgets in the layout has disappeared after a recent update … (one of them was the profile widget e.g.).

error in the console:

Uncaught TypeError: Cannot read property 'inlineBetween' of undefined

some errors in the admin error logs:

 TypeError (no implicit conversion of nil into String) /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/actionpack-4.2.8/lib/action_controller/metal/data_streaming.rb:68:in `file?' 

@angus
Hi Angus, may you confirm if this is related to layout plugin or the widgets?


(Angus McLeod) #65

This property does not appear anywhere in my code. Please attach the full error log so I can confirm.

I’m not seeing any errors using the layouts plugin with the latest version of Discourse.


(Pad Pors) #67

the problems were from another plugin Angus. I’ll disable the plugin to see if the widgets come back or not. and update here.

update:
@angus after removal of mathjax, layout and widgets are working fine.


(Pad Pors) #68

the profile widget is not working for the not-logged in users (logged in users are fine), after the common-mark updates; with this error in the browser console:

Error: Could not find module pretty-text/engines/discourse-markdown/helpers
    at s (_ember_jquery-a8dcbd3….js:59258)
    at require (_ember_jquery-a8dcbd3….js:59273)
    at h (pretty-text-bundle-1122bc3….js:sourcemap:1)
    at r (pretty-text-bundle-1122bc3….js:sourcemap:1)
    at a (application-6ed9515….js:sourcemap:1)
    at r (application-6ed9515….js:sourcemap:1)
    at t.html (plugin-third-party-3bbfdf2….js:sourcemap:1)
    at t.p [as draw] (application-6ed9515….js:sourcemap:48)
    at t.value (application-6ed9515….js:sourcemap:48)
    at r (_vendor-ee405da….js:7919)
u @ _ember_jquery-a8dcbd3….js:28913


(SMHassanAlavi) #69

I have solved this problem by using TextLib.cookAsync.
You could see fixed profile widget here


(Sam Saffron) #70

My plan is to totally deprecate cook from the library, we simply can not safely use it anymore. cookAsync is the only method allowed.


(Angus McLeod) #71

Note to users of this plugin (@Pad_Pors) . I’ve changed the way widgets are enabled and positioned. Rather than listing widgets in settings, you now select the position and whether the widget is pinned in a separate admin panel.

Instead of monkey patching the SiteSetting model, i.e.

SiteSetting.class_eval do
  @choices[:layouts_sidebar_left_widgets].push('profile')
end

You now add widgets in your plugin.rb like so:

DiscourseLayouts::WidgetHelper.add_widget('election-list')

This will make them appear on the list of widgets in the new admin panel.


(Roland) #72

Hey Angus. Do you have this working on the current version? My app wont launch with this right now.

Also I couldnt see the other one but the profile widget also isnt working on it.


(Angus McLeod) #73

Yup, it works fine with the latest version. Can you find any relevant logs?


15 AM

I don’t actually use the profile widget. I’ll take a look. Have you enabled it as described above?


(Angus McLeod) #74

Ok, I’ve updated the profile widget to use the new way of adding widgets.


(Roland) #75
0:  pry (0.10.4) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/pry-0.10.4.gemspec
Using unicorn 5.3.0
0:  unicorn (5.3.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/unicorn-5.3.0.gemspec
Using rbtrace 0.4.8
0:  rbtrace (0.4.8) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rbtrace-0.4.8.gemspec
Using rspec-core 3.6.0
0:  rspec-core (3.6.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-core-3.6.0.gemspec
Using rspec-expectations 3.6.0
0:  rspec-expectations (3.6.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-expectations-3.6.0.gemspec
Using rspec-mocks 3.6.0
0:  rspec-mocks (3.6.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-mocks-3.6.0.gemspec
Using sassc 1.11.2
0:  sassc (1.11.2) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/sassc-1.11.2.gemspec
Using unf 0.1.4
0:  unf (0.1.4) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/unf-0.1.4.gemspec
Using fast_xor 1.1.3
0:  fast_xor (1.1.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/fast_xor-1.1.3.gemspec
Fetching activesupport 4.2.9
Installing activesupport 4.2.9
0:  activesupport (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/activesupport-4.2.9.gemspec
Using loofah 2.0.3
0:  loofah (2.0.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/loofah-2.0.3.gemspec
Using nokogumbo 1.4.13
0:  nokogumbo (1.4.13) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/nokogumbo-1.4.13.gemspec
Using ruby-readability 0.7.0
0:  ruby-readability (0.7.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/ruby-readability-0.7.0.gemspec
Using sidekiq 5.0.3
0:  sidekiq (5.0.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/sidekiq-5.0.3.gemspec
Using mail 2.6.6
0:  mail (2.6.6) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/mail-2.6.6.gemspec
Using oga 2.10
0:  oga (2.10) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/oga-2.10.gemspec
Using aws-sdk-resources 2.5.3
0:  aws-sdk-resources (2.5.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/aws-sdk-resources-2.5.3.gemspec
Using ember-handlebars-template 0.7.5
0:  ember-handlebars-template (0.7.5) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/ember-handlebars-template-0.7.5.gemspec
Using webmock 3.0.1
0:  webmock (3.0.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/webmock-3.0.1.gemspec
Using oauth2 1.3.1
0:  oauth2 (1.3.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/oauth2-1.3.1.gemspec
Using listen 3.1.5
0:  listen (3.1.5) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/listen-3.1.5.gemspec
Using omniauth-oauth 1.1.0
0:  omniauth-oauth (1.1.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-oauth-1.1.0.gemspec
Using omniauth-openid 1.0.1
0:  omniauth-openid (1.0.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-openid-1.0.1.gemspec
Using pry-nav 0.2.4
0:  pry-nav (0.2.4) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/pry-nav-0.2.4.gemspec
Using pry-rails 0.3.4
0:  pry-rails (0.3.4) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/pry-rails-0.3.4.gemspec
Using rspec 3.6.0
0:  rspec (3.6.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-3.6.0.gemspec
Using rails-deprecated_sanitizer 1.0.3
0:  rails-deprecated_sanitizer (1.0.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rails-deprecated_sanitizer-1.0.3.gemspec
Using globalid 0.4.0
0:  globalid (0.4.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/globalid-0.4.0.gemspec
Fetching activemodel 4.2.9
Installing activemodel 4.2.9
0:  activemodel (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/activemodel-4.2.9.gemspec
Using shoulda-matchers 2.8.0
0:  shoulda-matchers (2.8.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/shoulda-matchers-2.8.0.gemspec
Using rails-html-sanitizer 1.0.3
0:  rails-html-sanitizer (1.0.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rails-html-sanitizer-1.0.3.gemspec
Using sanitize 4.5.0
0:  sanitize (4.5.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/sanitize-4.5.0.gemspec
Using aws-sdk 2.5.3
0:  aws-sdk (2.5.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/aws-sdk-2.5.3.gemspec
Using omniauth-oauth2 1.4.0
0:  omniauth-oauth2 (1.4.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-oauth2-1.4.0.gemspec
Using omniauth-twitter 1.3.0
0:  omniauth-twitter (1.3.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-twitter-1.3.0.gemspec
Using rspec-html-matchers 0.9.1
0:  rspec-html-matchers (0.9.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-html-matchers-0.9.1.gemspec
Using rails-dom-testing 1.0.8
0:  rails-dom-testing (1.0.8) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rails-dom-testing-1.0.8.gemspec
Fetching activejob 4.2.9
Installing activejob 4.2.9
0:  activejob (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/activejob-4.2.9.gemspec
Using active_model_serializers 0.8.3
0:  active_model_serializers (0.8.3) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/active_model_serializers-0.8.3.gemspec
Fetching activerecord 4.2.9
Installing activerecord 4.2.9
0:  activerecord (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/activerecord-4.2.9.gemspec
Using shoulda 3.5.0
0:  shoulda (3.5.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/shoulda-3.5.0.gemspec
Fetching onebox 1.8.17
Installing onebox 1.8.17
0:  onebox (1.8.17) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/onebox-1.8.17.gemspec
Using omniauth-facebook 4.0.0
0:  omniauth-facebook (4.0.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-facebook-4.0.0.gemspec
Fetching omniauth-github 1.3.0
Installing omniauth-github 1.3.0
0:  omniauth-github (1.3.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-github-1.3.0.gemspec
Using omniauth-google-oauth2 0.3.1
0:  omniauth-google-oauth2 (0.3.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-google-oauth2-0.3.1.gemspec
Using omniauth-instagram 1.0.2
0:  omniauth-instagram (1.0.2) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/omniauth-instagram-1.0.2.gemspec
Fetching actionview 4.2.9
Installing actionview 4.2.9
0:  actionview (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/actionview-4.2.9.gemspec
Using seed-fu 2.3.6
0:  seed-fu (2.3.6) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/seed-fu-2.3.6.gemspec
Using test_after_commit 1.1.0
0:  test_after_commit (1.1.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/test_after_commit-1.1.0.gemspec
Fetching actionpack 4.2.9
Installing actionpack 4.2.9
0:  actionpack (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/actionpack-4.2.9.gemspec
Fetching actionmailer 4.2.9
Installing actionmailer 4.2.9
0:  actionmailer (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/actionmailer-4.2.9.gemspec
Fetching railties 4.2.9
Installing railties 4.2.9
0:  railties (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/railties-4.2.9.gemspec
Using sprockets-rails 3.2.0
0:  sprockets-rails (3.2.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/sprockets-rails-3.2.0.gemspec
Using discourse-qunit-rails 0.0.9
0:  discourse-qunit-rails (0.0.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/discourse-qunit-rails-0.0.9.gemspec
Using jquery-rails 4.3.1
0:  jquery-rails (4.3.1) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/jquery-rails-4.3.1.gemspec
Using rspec-rails 3.6.0
0:  rspec-rails (3.6.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rspec-rails-3.6.0.gemspec
Fetching rails 4.2.9
Installing rails 4.2.9
0:  rails (4.2.9) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rails-4.2.9.gemspec
Using ember-rails 0.18.5
0:  ember-rails (0.18.5) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/ember-rails-0.18.5.gemspec
Using rails_multisite 1.0.6
0:  rails_multisite (1.0.6) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/rails_multisite-1.0.6.gemspec
Using spork-rails 4.0.0
0:  spork-rails (4.0.0) from /var/www/discourse/vendor/bundle/ruby/2.3.0/specifications/spork-rails-4.0.0.gemspec
Bundle complete! 96 Gemfile dependencies, 173 gems now installed.
Gems in the group development were not installed.
Bundled gems are installed into ./vendor/bundle.

I, [2017-08-09T07:46:56.949898 #15]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/var/www/discourse/plugins/dl-custom-content/plugin.rb:9:in `block (2 levels) in activate!'
/var/www/discourse/plugins/dl-custom-content/plugin.rb:8:in `class_eval'
/var/www/discourse/plugins/dl-custom-content/plugin.rb:8:in `block in activate!'
/var/www/discourse/lib/plugin/instance.rb:208:in `block in notify_after_initialize'
/var/www/discourse/lib/plugin/instance.rb:206:in `each'
/var/www/discourse/lib/plugin/instance.rb:206:in `notify_after_initialize'
/var/www/discourse/config/application.rb:209:in `block (2 levels) in <class:Application>'
/var/www/discourse/config/application.rb:209:in `each'
/var/www/discourse/config/application.rb:209:in `block in <class:Application>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/lazy_load_hooks.rb:44:in `each'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in `run'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:54:in `run_initializers'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:352:in `initialize!'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in `method_missing'
/var/www/discourse/config/environment.rb:5:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `block in require'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:240:in `load_dependency'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:274:in `require'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:328:in `require_environment!'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
I, [2017-08-09T07:47:03.176969 #15]  INFO -- :
I, [2017-08-09T07:47:03.177937 #15]  INFO -- : Terminating async processes
I, [2017-08-09T07:47:03.178041 #15]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/9.5/bin/postmaster -D /etc/postgresql/9.5/main pid: 44
I, [2017-08-09T07:47:03.178422 #15]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 157
2017-08-09 07:47:03.178 UTC [44] LOG:  received fast shutdown request
2017-08-09 07:47:03.178 UTC [44] LOG:  aborting any active transactions
157:signal-handler (1502264823) 2017-08-09 07:47:03.179 UTC [51] LOG:  autovacuum launcher shutting down
Received SIGTERM scheduling shutdown...
2017-08-09 07:47:03.185 UTC [48] LOG:  shutting down
157:M 09 Aug 07:47:03.238 # User requested shutdown...
157:M 09 Aug 07:47:03.238 * Saving the final RDB snapshot before exiting.
2017-08-09 07:47:03.261 UTC [48] LOG:  database system is shut down
157:M 09 Aug 07:47:03.328 * DB saved on disk
157:M 09 Aug 07:47:03.328 # Redis is now ready to exit, bye bye...


FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 464 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:108:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"bundle_exec", "cmd"=>["su discourse -c 'bundle install --deployment --verbose --without test --without development'", "su discourse -c 'bundle exec rake db:migrate'", "su discourse -c 'bundle exec rake assets:precompile'"]}
5e2f206b07fc093adb6a40ae8494c03ec58e0c19cc9a08484356663165da3c64
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one
root@server70:/var/discourse#

This is what I get. The profile widget was ok on here but even in layouts i have it saved but its not showing up on my front page.

Edit the profile widget is showing now after I rebuilt the app.


(Angus McLeod) #76

It looks like the error is coming from the dl-custom-content plugin / widget, not the layouts plugin.

Remove that widget and try again.


(Roland) #77

Ok. Guess that’s the one I need to work. Do you have that one working yet?


(Angus McLeod) #78

I didn’t build that one.

Here’s how you can fix it if you want to use it:

  1. Fork the dl-custom-content repo.

  2. Change these lines

    SiteSetting.class_eval do
      @choices[:layouts_sidebar_right_widgets].push('dl-custom-content')
      @choices[:layouts_sidebar_left_widgets].push('dl-custom-content')
    end
    

    to

    DiscourseLayouts::WidgetHelper.add_widget('dl-custom-content')
    
  3. Change the plugin url in your app.yml to your fork.


(Roland) #79

Ah ok. Thanks Angus!


(Roland) #80

No luck. Made the changes and it still failed when ./launcher rebuild app


(Tobias) #81

Did you manage to fix it @Ham :-)?


(Roland) #82

Never. Just removed it and made my css changes back to how it was prior. My site was live and couldn’t have it down any longer needed.