Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ RUN apt-get update -qq && \
curl \
netcat-traditional \
chromium \
libyaml-dev
libyaml-dev \
fonts-liberation \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Add Node, required for asset pipeline.
RUN curl -sL https://deb.nodesource.com/setup_22.x | bash - && \
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/pdf.scss

This file was deleted.

14 changes: 2 additions & 12 deletions app/views/layouts/pdf.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@
<html>
<head>
<title><%= yield(:title) %></title>
<% css = '' %>
<% candidates = [] %>
<% candidates.concat(Dir.glob(Rails.root.join('app', 'assets', 'builds', '*.css').to_s)) %>
<% candidates.concat(Dir.glob(Rails.root.join('public', 'assets', '*.css').to_s)) %>
<% css = candidates.filter_map do |path|
begin
File.read(path)
rescue => e
Rails.logger.warn "Could not read compiled css from #{path}: #{e.message}"
nil
end
end.join("\n") %>
<% app_css_path = Rails.root.join('app', 'assets', 'builds', 'application.css') %>
<% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %>
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The File.read operation is not wrapped in error handling. If the file exists but cannot be read due to permissions or I/O errors, this will raise an exception and break PDF generation. Consider adding a rescue block similar to the error handling that was present in the previous implementation to gracefully handle read failures.

Suggested change
<% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %>
<% css =
if File.exist?(app_css_path)
begin
File.read(app_css_path)
rescue StandardError
''
end
else
''
end
%>

Copilot uses AI. Check for mistakes.
<style type="text/css">
<%= css.html_safe %>
</style>
Expand Down
11 changes: 8 additions & 3 deletions config/initializers/grover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
# https://github.com/Studiosity/grover

Grover.configure do |config|
# Common PDF options
config.options = {
options = {
format: 'A4',
print_background: true,
prefer_css_page_size: false,
display_url: "https://#{Rails.application.config.x.sofia_host}"

}

unless Rails.env.development?
options[:executable_path] = '/usr/bin/chromium'
options[:launch_args] = ['--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
end

config.options = options
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lint:styles:fix": "stylelint 'app/**/*.s+(a|c)ss' 'app/**/*.vue' --ignore-path .gitignore --fix",
"build": "webpack --config webpack.config.js",
"watch": "webpack --config webpack.config.js --watch",
"build:css": "sass ./app/assets/stylesheets/application.scss:./app/assets/builds/application.css ./app/assets/stylesheets/pdf.scss:./app/assets/builds/pdf.css --no-source-map --load-path=node_modules",
"build:css": "sass ./app/assets/stylesheets/application.scss:./app/assets/builds/application.css --no-source-map --load-path=node_modules",
"update:font": "ruby bin/copy_fontawesome_fonts"
},
"dependencies": {
Expand Down
Loading