Skip to content

Commit 69c9cc4

Browse files
v 0.75 (See update_log.md)
1 parent 2289e6d commit 69c9cc4

File tree

20 files changed

+122
-18
lines changed

20 files changed

+122
-18
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ gem 'image_processing'
7171
gem 'open-uri'
7272
gem 'pg'
7373
gem 'rubyzip'
74+
gem 'reverse_markdown'
7475

7576
gem 'sidekiq'
7677

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ GEM
202202
responders (3.0.1)
203203
actionpack (>= 5.0)
204204
railties (>= 5.0)
205+
reverse_markdown (2.0.0)
206+
nokogiri
205207
rmagick (4.2.2)
206208
rollbar (3.2.0)
207209
rspec-core (3.10.1)
@@ -325,6 +327,7 @@ DEPENDENCIES
325327
rack-mini-profiler (~> 2.0)
326328
rails (~> 6.1.2)
327329
redcarpet
330+
reverse_markdown
328331
rmagick
329332
rollbar
330333
rubyzip

app/assets/stylesheets/base.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ $color-black: #000000;
105105
}
106106
}
107107

108+
body#bg-clear{
109+
background-color:$bg;
110+
footer{
111+
color: $font;
112+
}
113+
pre{
114+
color: $font;
115+
background-color: $bg;
116+
border: none;
117+
white-space: pre-wrap;
118+
word-wrap: break-word;
119+
}
120+
}
121+
108122
table {
109123
border-collapse: collapse;
110124
}

app/assets/stylesheets/ruby_theme.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@import "base";
22

3-
$bg: #ffffff;
3+
$bg: #f2f2f4;
44

55
$color-link-light: #bd6d76;
66
$color-link: #df4655;
@@ -12,7 +12,7 @@ $color-avatar-border: #1b1b1c;
1212
$color-privacy-registered-p: #1375b2;
1313
$color-privacy-registered: #5cb85c;
1414
$color-privacy-me-p: #df4655;
15-
$color-privacy-me: #4e518b;
15+
$color-privacy-me: #5659e0;
1616

1717
$color-wrapper: #515151;
1818

@@ -53,7 +53,7 @@ $color-code-bg: #222426;
5353
$font: #000000;
5454
$font-link: #b3b3b3;
5555

56-
$color-white: #f0f0f0;
56+
$color-white: #fcfcff;
5757
$color-black: #000000;
5858

5959
@include base($bg, $color-darkpurple, $color-code-bg,

app/commands/export_files.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ class ExportFiles
55

66
def initialize(post)
77
@post = post
8+
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: false, fenced_code_blocks: false, disable_indented_code_blocks: true, autolink: false, tables: false, underline: false, highlight: false)
89
end
910

1011
def call
1112

1213
title = @post.title
13-
content_text = @post.get_content
14+
content_text = ReverseMarkdown.convert(@markdown.render(@post.get_content), unknown_tags: :pass_through)
1415
text = title.present? ? "## #{title}\n\n#{content_text}" : "#{content_text}"
1516

1617
post_dir = "tmp/export/#{@post.id.to_s}"

app/controllers/posts_controller.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class PostsController < ApplicationController
22

3-
before_action :authenticate_user!, except: [:rss, :show]
4-
before_action :check_admin, except: [:rss, :index, :show]
3+
before_action :authenticate_user!, except: [:rss, :show, :export, :raw]
4+
before_action :check_admin, except: [:rss, :index, :show, :export, :raw]
55

66
def check_admin
77
redirect_to root_path unless current_user.is_admin
@@ -106,7 +106,7 @@ def rss
106106
def export
107107
@post = Post.find_by_id(params[:id])
108108
if @post.present?
109-
return render file: "#{Rails.root}/public/404.html", layout: false, status: 404 if !@post.check_privacy(current_user) || (@post.user != current_user)
109+
return render file: "#{Rails.root}/public/404.html", layout: false, status: 404 if @post.user != current_user
110110
else
111111
return render file: "#{Rails.root}/public/404.html", layout: false, status: 404
112112
end
@@ -118,6 +118,16 @@ def export
118118
send_file(file[:path], filename: file[:filename], type: file[:type])
119119
end
120120

121+
def raw
122+
@post = Post.find_by_id(params[:id])
123+
if @post.present?
124+
return render file: "#{Rails.root}/public/404.html", layout: false, status: 404 unless @post.check_privacy(current_user)
125+
else
126+
return render file: "#{Rails.root}/public/404.html", layout: false, status: 404
127+
end
128+
render 'posts/raw', layout: 'clear'
129+
end
130+
121131
def import
122132
if params[:file].present?
123133
file_blob = ActiveStorage::Blob.find_signed!(params[:file])

app/helpers/posts_helper.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ def display_attachments(post)
9595
150
9696
else
9797
100
98-
end
98+
end
99+
100+
documents = post.get_content_attachments.select{ |b| !b.image? && !b.video? && !b.audio? }
101+
documents.each do |att|
102+
content += "<br><a target=\"_blank\" href=\"#{url_for(att)}\"> #{I18n.t("posts.download")} #{truncate(att.filename.to_s, length: 100)} </a>"
103+
end if documents.any?
104+
content += "<br><br>" if documents.any?
105+
99106
post.get_content_attachments&.each do |att|
100107
case
101108
when att.image?

app/views/layouts/application.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>/dev/wtde</title>
4+
<title><%=Rails.configuration.credentials[:title]%></title>
55
<%= csrf_meta_tags %>
66
<%= csp_meta_tag %>
77

app/views/layouts/clear.html.erb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title><%=Rails.configuration.credentials[:title]%></title>
5+
<%= csrf_meta_tags %>
6+
<%= csp_meta_tag %>
7+
8+
<%= stylesheet_link_tag "#{current_theme}", media: 'all', 'data-turbolinks-track': 'reload' %>
9+
</head>
10+
11+
<body>
12+
<%= yield %>
13+
</body>
14+
15+
</html>

app/views/posts/edit.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
<div id="attachments" class="tab-pane">
2525
<h3><%= I18n.t("posts.current_attachments") %>:</h3>
2626
<% if platforms.empty? || platforms.values.exclude?(true)%>
27-
<div class="dropzone dropzone-default dz-clickable" data-controller="dropzone" data-dropzone-max-file-size="10" data-dropzone-max-files="10">
27+
<div class="dropzone dropzone-default dz-clickable" data-controller="dropzone" data-dropzone-max-file-size="<%=Rails.configuration.credentials[:max_file_size]%>" data-dropzone-max-files="<%=Rails.configuration.credentials[:max_upload_files]%>">
2828
<%= f.file_field :attachments, multiple: true, direct_upload: true, data: { target: 'dropzone.input' } %>
2929
<div class="dropzone-msg dz-message needsclick">
3030
<h3 class="dropzone-msg-title"><%= I18n.t("posts.attachments_msg_title") %></h3>
31-
<span class="dropzone-msg-desc text-sm"><%= I18n.t("posts.attachments_msg_description") %></span>
31+
<span class="dropzone-msg-desc text-sm"><%= "#{I18n.t("posts.attachments_msg_max_size")}: #{Rails.configuration.credentials[:max_file_size]} MB; #{I18n.t("posts.attachments_msg_max_count")}: #{Rails.configuration.credentials[:max_upload_files]}" %></span>
3232
</div>
3333
</div>
3434
<% end %>

0 commit comments

Comments
 (0)