From 4593bf2b2a35055deb0290c24f07d61aab382f40 Mon Sep 17 00:00:00 2001
From: ricola
Date: Sat, 27 Sep 2025 17:29:31 +0200
Subject: [PATCH 1/2] Ignore config/environments/production.rb as well
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 5142bb0..3bddc9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ locale
db/*.sqlite3
db/*.sqlite3-*
config/environments/development.rb
+config/environments/production.rb
vedia.log
From 758b01518a5eebede18e93ef03d1d850069a14b7 Mon Sep 17 00:00:00 2001
From: ricola
Date: Sat, 27 Sep 2025 18:57:36 +0200
Subject: [PATCH 2/2] Render descriptions as Markdown
---
Gemfile | 1 +
Gemfile.lock | 5 +++++
vedia.rb | 19 +++++++++++++++++++
views/style.erb | 5 +++++
views/votes_edit.erb | 6 +++---
views/votes_new.erb | 2 +-
views/votes_open.erb | 4 ++--
views/votes_show_closed.erb | 2 +-
views/votes_show_draft.erb | 4 ++--
views/votes_show_open.erb | 6 +++---
10 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/Gemfile b/Gemfile
index 30898d0..b7a96f1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,3 +12,4 @@ gem 'bcrypt'
gem 'gettext'
gem 'chartkick'
gem 'mail'
+gem 'redcarpet'
diff --git a/Gemfile.lock b/Gemfile.lock
index c009320..c73cbba 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -77,6 +77,7 @@ GEM
rackup (2.2.1)
rack (>= 3)
rake (13.2.1)
+ redcarpet (3.6.1)
ruby2_keywords (0.0.5)
securerandom (0.4.1)
sinatra (4.1.1)
@@ -92,6 +93,9 @@ GEM
singleton (0.3.0)
sqlite3 (2.6.0)
mini_portile2 (~> 2.8.0)
+ sqlite3 (2.6.0-arm64-darwin)
+ sqlite3 (2.6.0-x86_64-darwin)
+ sqlite3 (2.6.0-x86_64-linux-gnu)
text (1.3.1)
tilt (2.6.0)
timeout (0.4.3)
@@ -114,6 +118,7 @@ DEPENDENCIES
puma
rackup
rake
+ redcarpet
sinatra
sinatra-activerecord
sqlite3
diff --git a/vedia.rb b/vedia.rb
index cab3dac..105e5b9 100644
--- a/vedia.rb
+++ b/vedia.rb
@@ -6,6 +6,7 @@ require 'securerandom'
require 'chartkick'
require 'mail'
require 'tzinfo'
+require 'redcarpet'
include GetText
@@ -479,4 +480,22 @@ helpers do
def format_date_and_time(timestamp)
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F %R')} (#{session[:timezone].gsub('_', ' ')})"
end
+
+ def markdown(markdown)
+ renderer = Redcarpet::Render::HTML.new(hard_wrap: true,
+ filter_html: true,
+ no_styles: true,
+ safe_links_only: true)
+ parser = Redcarpet::Markdown.new(renderer, tables: true,
+ autolink: true,
+ strikethrough: true,
+ space_after_headers: true,
+ superscript: true,
+ underline: true,
+ highlight: true,
+ quote: true,
+ footnotes: true)
+ parser.render(markdown)
+ end
+
end
diff --git a/views/style.erb b/views/style.erb
index c5b0e2b..1cbad52 100644
--- a/views/style.erb
+++ b/views/style.erb
@@ -2,6 +2,11 @@
color: red;
}
+textarea {
+ width: 80em;
+ height: 20em;
+}
+
<% settings.values.each do |v| %>
.value-<%= v[:id] %> {
background: <%= v[:color] %>;
diff --git a/views/votes_edit.erb b/views/votes_edit.erb
index 7ee4e93..4f9eca6 100644
--- a/views/votes_edit.erb
+++ b/views/votes_edit.erb
@@ -7,7 +7,7 @@
-
+
@@ -16,7 +16,7 @@
<% @vote.candidates.each do |candidate| %>
<%= candidate.name %>
-<%= candidate.description %>
+<%= markdown(candidate.description) %>
@@ -31,7 +31,7 @@
-
+
diff --git a/views/votes_new.erb b/views/votes_new.erb
index 66d3e23..505289d 100644
--- a/views/votes_new.erb
+++ b/views/votes_new.erb
@@ -7,7 +7,7 @@
-
+
diff --git a/views/votes_open.erb b/views/votes_open.erb
index 6cf345c..0290bd1 100644
--- a/views/votes_open.erb
+++ b/views/votes_open.erb
@@ -18,11 +18,11 @@ opening it.") %>
<%= @vote.title %>
-<%= @vote.description %>
+<%= markdown(@vote.description) %>
<%= _("Candidates") %>
<% @vote.candidates.each do |candidate| %>
<%= candidate.name %>
-<%= candidate.description %>
+<%= markdown(candidate.description) %>
<% end %>
diff --git a/views/votes_show_closed.erb b/views/votes_show_closed.erb
index 93f41a3..5ce1aa4 100644
--- a/views/votes_show_closed.erb
+++ b/views/votes_show_closed.erb
@@ -4,7 +4,7 @@
<%= _("Closing date: %{date}" % { date: format_date_and_time(@vote.expire_on) }) %>
<% end %>
-<%= @vote.description %>
+<%= markdown(@vote.description) %>
<% unless @vote.ratings.blank? %>
diff --git a/views/votes_show_draft.erb b/views/votes_show_draft.erb
index 8e3e51d..c521143 100644
--- a/views/votes_show_draft.erb
+++ b/views/votes_show_draft.erb
@@ -1,6 +1,6 @@
<%= @vote.title %> <%= _("(Draft)") %>
-<%= @vote.description %>
+<%= markdown(@vote.description) %>
<%= _("Organizers") %>
@@ -14,5 +14,5 @@
<% @vote.candidates.each do |candidate| %>
<%= candidate.name %>
-<%= candidate.description %>
+<%= markdown(candidate.description) %>
<% end %>
diff --git a/views/votes_show_open.erb b/views/votes_show_open.erb
index ae75c4b..d5f5a8f 100644
--- a/views/votes_show_open.erb
+++ b/views/votes_show_open.erb
@@ -4,7 +4,7 @@
<%= _("Closing date: %{date}" % { date: format_date_and_time(@vote.expire_on) }) %>
<% end %>
-<%= @vote.description %>
+<%= markdown(@vote.description) %>
<%= _("Your ratings") %>
@@ -14,8 +14,8 @@
<% rating = @vote.ratings.find { |rating| rating.user == current_user and rating.candidate == candidate } %>
<% value = rating ? rating.value : 0 %>
- <%= candidate.name %>
- <%= candidate.description %>
+ <%= candidate.name %>
+ <%= markdown(candidate.description) %>