I have standard Rails 4.2 app, without compass.
I found similar question but with compass usage.
Recently in the project directory appears folder ".sass-cache"
All what i want , it's just move it to tmp.
In application.rb tried:
module Sirius41
class Application < Rails::Application
...
config.sass.cache_location = Rails.root.join('tmp', '.sass-cache').to_s
ap config.sass
end
end
sass_options = {:cache_path => Rails.root.join('tmp', '.sass-cache').to_s}
But it don't change the cache location.
Rails sass config values:
{
:preferred_syntax => :scss,
:cache => true,
:read_cache => true,
:line_comments => true,
:load_paths => [],
:logger => #<Sass::Rails::Logger:0x007f80d9148118 #log_level=:debug>,
:cache_location => "/home/anton/rubyprojects/sirius42/tmp/.sass-cache"
}
Related
I am building a simple Progressive Web Application with Python Django and django-pwa package. I have set up everything but offline functionality is not working. At this point, service workers (SW) are installed and dev tools recognize application as PWA. But when I check "offline" in devtools->Application and reload the web page there is a "No internet connection" error.
Here are my SW settings:
var staticCacheName = 'djangopwa-v1';
var filesToCache = [
'/',
'/x_offline/',
'/static/x_django_pwa/images/my_app_icon.jpg',
'/media/images/bfly1.2e16d0ba.fill-320x240.jpg',
];
// Cache on install
self.addEventListener("install", event => {
this.skipWaiting();
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
)
});
// Clear cache on activate
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames
.filter(cacheName => (cacheName.startsWith("djangopwa-v1")))
.filter(cacheName => (cacheName !== staticCacheName))
.map(cacheName => caches.delete(cacheName))
);
})
);
});
// Serve from Cache
self.addEventListener("fetch", event => {
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
.catch(() => {
return caches.match('x_offline');
})
)
});
Listed settings are almost the same as default one from django-pwa repo
When I load the page for the first time I see that requests are also made for the urls listed in SW and all of them have status 200. In the cache storage I see cache with paths set in SW. So I don't understand what I do wrong.
Not sure if this additional info is useful, but: when I set SW to offline and reload the web page the cache storage is empty.
The issue is in the settings that django-pwa repo provided.
They accidentally added sign , at the end of the scope variable and so if you copy settings you copy with incorrect scope setting (PWA_APP_SCOPE = '/',) and it brakes offline mode. I am going to contact with repo admins so that to fix the issue for the next users.
I'm following the How to Configure SimpleSAMLphp for Drupal 8 on Acquia instruction. I'm at the bottom where it says, "SimpleSAMLphp_auth module settings. I personally recommend to store configuration for SimpleSAMLphp_auth module settings in settings.php." Once I copied the code he has in that code snippet to my settings.php file (pasted it at the bottom) and push it to Acquia, I got this error when I tried to login via the dev.mysite.com/user url.
The website encountered an unexpected error. Please try again later. Recoverable fatal error: Object of class Drupal\Core\Link could not be converted to string in Drupal\Component\Utility\Xss::filter() (line 67 of core/lib/Drupal/Component/Utility/Xss.php).
The code shown below is what I have in my settings.php file.
$config['simplesamlphp_auth.settings'] = [
// Basic settings.
'activate' => TRUE, // Enable or Disable SAML login.
'auth_source' => 'default-sp',
'login_link_display_name' => 'Login with your SSO account',
'register_users' => TRUE,
'debug' => FALSE,
// Local authentication.
'allow' => [
'default_login' => TRUE,
'set_drupal_pwd' => TRUE,
'default_login_users' => '',
'default_login_roles' => [
'authenticated' => FALSE,
'administrator' => 'administrator',
],
],
'logout_goto_url' => '',
// User info and syncing.
// `unique_id` is specified in Transient format, otherwise this should be `UPN`
// Please talk to your SSO adminsitrators about which format you should be using.
'unique_id' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn',
'user_name' => 'uid',
'mail_attr' => 'mail',
'sync' => [
'mail' => FALSE,
'user_name' => FALSE,
],
];
If I commented out this whole block of code in my setings.php file then I can login to my dev.mysite.com/user drupal site. One other thing I'm not clear is, do I "Check Activate authentication via SimpleSAMLphp option" first then copied the code snippet to my settings.php file and push to Acquia or the other way around?
Any help is much appreciated.
It seems that update to version 8.x-3.0-rc2 resolves the error above. However, looks like it introduces another issues, "This site can't be reached" and redirected the site to port 80 instead.
I am using barryvdh elfinder package to display all the files and folders from my AWS S3 bucket. In elfinders config I have defined root as follows:
[
'driver' => 'Flysystem',
'path' => '',
'defaults' => array('read' => true, 'write' => true),
'filesystem' => new \League\Flysystem\Filesystem(
new \League\Flysystem\AwsS3v2\AwsS3Adapter( \Aws\S3\S3Client::factory(array(
'key' => 'key',
'secret' => 'secret'
)), 'bucket-name'))
]
This seems to work fine, all the files are being displayed. But the folders are not being listed. If I create a folder, it shows error message, but the folder is being created in the bucket, only it doesnt show any folders.
Can anyone help me with the solution.
I'm working on an Rails 4.1 engine that handles user uploads of photos and videos. I'm using Mongoid-Paperclip to handle the uploads and Paperclip-av-transcoder to encode the videos into several formats. All files are stored at S3. All of that works fine, but as you can expect, encoding the videos can take quite some time, so the next step is to make that happen in the background. I did some googling and found Delayed_Paperclip that seems to do what I need. After that it seemed that Sidekiq was the best option for handling the background processing.
Now the problem is, I can't make all this work together. Running my unit tests I get NoMethodError: undefined method 'process_in_background' so it seems the problem resides on Delayed_Paperclip, although there is no special setup to it.
This is the model firing the problem
module MyEngine
class Video
include Mongoid::Document
include Mongoid::Paperclip
has_mongoid_attached_file :file,
:path => ':hash.:extension',
:hash_secret => "the-secret",
:storage => :s3,
:url => ':s3_domain_url',
:s3_credentials => File.join(Rails.root, 'config', 's3.yml'),
:bucket => "my-bucket-#{Rails.env}",
:styles => {
:mp4 => { :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264', :acodec => 'copy' } } },
:ogg => { :format => 'ogg', :auto_rotate => true },
:webm => { :format => 'webm', :auto_rotate => true },
:thumb => { :geometry => "250x187#", :format => 'jpg', :time => 10, :auto_rotate => true }
},
:processors => [:transcoder]
validates_attachment :file, :content_type => { :content_type => ["video/x-flv", "video/mp4", "video/ogg", "video/webm", "video/x-ms-wmv", "video/x-msvideo", "video/quicktime", "video/3gpp"] }
process_in_background :file
end
end
I've tried adding require "delayed_paperclip" to the lib/myengine/myengine.rb file but that didn't help.
Regarding Sidekiq, I have added to the test_helper.rb the following:
require 'sidekiq/testing'
Sidekiq::Testing.inline!
Note that I did not forget to run bundle install and Redis is up and running. I'm using Mongoid, not active record.
What I am doing wrong? Has anyone successfully used this setup? Is there another combination of gems that I should try?
Aditional info:
Delayed_paperclip 2.9.1
Mongoid 4.0.2
Mongoid-Paperclip 0.0.9
Paperclip 4.2.1
Paperclip-av-transcoder 0.6.4
Rails 4.1.9
Sidekiq 3.5.0
I've been digging through the code of delayed_paperclip and it is definitely tied to ActiveRecord so not compatible with Mongoid. I gave a try to mongoid_paperclip_queue but that gem hasn't been updated in 4 years and doesn't seem to work with the current versions of rails/mongoid/paperclip as far as I can tell.
I therefore decided the best way to solve my issue would be to override the code of delayed_paperclip that integrates with ActiveRecord and make it instead work with Mongoid.
This is what I ended up doing, and seems to be working fine so far:
lib/myengine.rb
require "mongoid_paperclip"
require "paperclip/av/transcoder"
require "delayed_paperclip"
require "myengine/engine"
module Myengine
end
DelayedPaperclip::Railtie.class_eval do
initializer 'delayed_paperclip.insert_into_mongoid' do |app|
ActiveSupport.on_load :mongoid do
DelayedPaperclip::Railtie.insert
end
if app.config.respond_to?(:delayed_paperclip_defaults)
DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
end
end
# Attachment and URL Generator extends Paperclip
def self.insert
Paperclip::Attachment.send(:include, DelayedPaperclip::Attachment)
Paperclip::UrlGenerator.send(:include, DelayedPaperclip::UrlGenerator)
end
end
DelayedPaperclip::InstanceMethods.class_eval do
def enqueue_post_processing_for name
DelayedPaperclip.enqueue(self.class.name, read_attribute(:id).to_s, name.to_sym)
end
end
Then all you need is to include the delayed_paperclip glue to the model:
module Myengine
class Video
include Mongoid::Document
include Mongoid::Paperclip
include DelayedPaperclip::Glue # <---- Include this
has_mongoid_attached_file :file,
:path => ':hash.:extension',
:hash_secret => "the-secret",
:storage => :s3,
:url => ':s3_domain_url',
:s3_credentials => File.join(Rails.root, 'config', 's3.yml'),
:bucket => "my-bucket-#{Rails.env}",
:styles => {
:mp4 => { :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264', :acodec => 'copy' } } },
:ogg => { :format => 'ogg', :auto_rotate => true },
:webm => { :format => 'webm', :auto_rotate => true },
:thumb => { :geometry => "250x187#", :format => 'jpg', :time => 10, :auto_rotate => true }
},
:processors => [:transcoder]
validates_attachment :file, :content_type => { :content_type => ["video/x-flv", "video/mp4", "video/ogg", "video/webm", "video/x-ms-wmv", "video/x-msvideo", "video/quicktime", "video/3gpp"] }
process_in_background :file
end
end
Hopefully this will save somebody else all the trouble.
I'm having a similar problem to this issue, except I'm unable to modify the path at all.
I'm using Spree 2.2 which uses paperclip 3.4.2
I'm trying to modify the paperclip defaults to change the image path. All of the other configuration is working.
Myapp::Application.configure do
config.paperclip_defaults = {
:storage => :s3,
:s3_protocol => 'https',
:s3_host_name => "s3-eu-west-1.amazonaws.com",
:path => ":rails_root/public/:attachment/:id/:style/:basename.:extension",
:url => "/:attachment/:id/:style/:basename.:extension",
:s3_credentials => {
:bucket => 'xxx',
:access_key_id => "xxx",
:secret_access_key => "xxx"
}
}
end
But with this code the URL is like so:
https://s3-eu-west-1.amazonaws.com/bucketname/home/username/path/to/project/public/spree/products/24/original/ror_baseball.jpeg?1390110939
I've tried adding the following to that config block:
config.attachment_path = '/spree/products/:id/:style/:basename.:extension'
I've also tried adding the following to the config/initializers/paperclip.rb
Paperclip::Attachment.default_options[:url] = "/:attachment/:id/:style/:basename.:extension"
Paperclip::Attachment.default_options[:path] = ":rails_root/public/:attachment/:id/:style/:basename.:extension"
And also tried:
Paperclip::Attachment.default_options.merge!(
:path => ":rails_root/public/:attachment/:id/:style/:basename.:extension",
:url => "/:attachment/:id/:style/:basename.:extension"
)
Any ideas?
UPDATE: opened ticket on github
For Spree 2.2 (not 2.1), use the following code in initializers/spree.rb:
Spree::Image.attachment_definitions[:attachment][:url] = ':path'
Spree::Image.attachment_definitions[:attachment][:path] = '/spree/products/:id/:style/:basename.:extension'
The rest of the configuration should be set as 2.1 (see here for details).
I believe the /home/username/path/to/project/ part is being added by the :rails_root portion of your :path configuration.
If you look at the source code at:
https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/attachment.rb
You will see that the default values are as follows:
:path => ":rails_root/public:url",
:url => "/system/:class/:attachment/:id_partition/:style/:filename",
What if you set the following:
:path => ":url",
:url => "/spree/products/:id/:style/:basename.:extension",
Let me know what these do for you and we can see what else you need to do in order to get this working properly.
After a quick Google search, prompted by your comment I figured it out. I believe the answer is here, in the Spree documentation:
http://guides.spreecommerce.com/user/configuring_images.html
UPDATE: Apparently This is only available on older versions. In newer versions, it looks like you need to override Spree::Image. This is defined in vendor/bundle/gems/spree_core-2.2.0/app/models/spree/image.rb.