diaspora/diaspora

Adding Controller yields error

hasandiwan opened this issue · 3 comments

I'd like to offer diaspora installations to clients, each with their own CSS to modify their look and feel. While I'm open to suggestions, the way I'm proposing doing so is by having a stylesheets model with the request CIDR, matched using ruby's ipaddr class -- https://ruby-doc.org/stdlib-2.5.1/libdoc/ipaddr/rdoc/IPAddr.html -- and then having the contents of the style tag. In my controller, I plan on having something like this:

def custom_stylesheet
if request_ip_address.subnet ~ /18.0.0.0:255.0.0.0/
return 'mit.css'
end
if request_ip_address.subnet ~ /128.113.0.0/255.255.0.0/
return 'rpi.css'
end
end

To store this info, I'm trying to create a new model/controller, when I try this, I am awarded with the following error:

$ bundle exec bin/rails g controller stylesheet:text subnet:cidr
/mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/pry-byebug-3.8.0/lib/pry-byebug/control_d_handler.rb:5: warning: control_d_handler's arity of 2 parameters was deprecated (eval_string, pry_instance). Now it gets passed just 1 parameter (pry_instance)
**************************************************
?? WARNING: Sidekiq testing API enabled, but this is not the test environment.  Your jobs will not go to Redis.
**************************************************
[2021-11-20T04:27:27] INFO  PID-5211 TID-17190101540 DiasporaFederation: successfully configured the federation library
root  ............................................  *debug      -T
- <Appenders::Stdout name="stdout">
- <Appenders::RollingFile name="file">
  ActionView::Base  ..............................  *debug  +A  -T
  ActiveRecord::Base  ............................  *debug  +A  -T
  ActiveSupport::Cache::NullStore  ...............   debug  +A  -T
  DiasporaFederation  ............................   debug  +A  -T
    DiasporaFederation::Salmon::MagicEnvelope  ...   *info  +A  -T
  Logging  .......................................    *off  -A  -T
  Rails  .........................................   debug  +A  -T
bundler: failed to load command: bin/rails (bin/rails)
NameError: wrong constant name Stylesheet:textController
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators/base.rb:267:in `const_defined?'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators/base.rb:267:in `block in class_collisions'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators/base.rb:258:in `each'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators/base.rb:258:in `class_collisions'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators/named_base.rb:226:in `block in check_class_collision'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `block in invoke_all'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `each'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `map'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:134:in `invoke_all'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/group.rb:232:in `dispatch'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/generators.rb:276:in `invoke'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/commands/generate/generate_command.rb:26:in `perform'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/command/base.rb:69:in `perform'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/command.rb:46:in `invoke'
  /mnt/extra/ec2-user/.rvm/gems/ruby-2.6.6@diaspora/gems/railties-5.2.6/lib/rails/commands.rb:18:in `<top (required)>'
  bin/rails:4:in `require'
  bin/rails:4:in `<top (required)>'

Anyone have any idea or know an easier way to accomplish what I'm trying to do? Many thanks, in advance!

Happens only in production mode, development works fine

Hello @hasandiwan and thank you for your interest for the project. Diaspora already has a built-in theme system, I think you should have a look there first it would be much easier to maintain.