Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
42e23f9e
Commit
42e23f9e
authored
3 years ago
by
pabois
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:noesya/osuny
parents
6bd182c1
7cd9d229
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/helpers/admin/application_helper.rb
+1
-1
1 addition, 1 deletion
app/helpers/admin/application_helper.rb
app/models/communication/website/imported/post.rb
+22
-3
22 additions, 3 deletions
app/models/communication/website/imported/post.rb
config/locales/fr.yml
+7
-0
7 additions, 0 deletions
config/locales/fr.yml
with
30 additions
and
4 deletions
app/helpers/admin/application_helper.rb
+
1
−
1
View file @
42e23f9e
...
...
@@ -63,7 +63,7 @@ module Admin::ApplicationHelper
def
prepare_for_github
(
html
)
text
=
html
.
to_s
text
=
sanitize
text
,
tags:
%w(table a figure img figcaption i em b strong h2 h3 h4 h5 h6 blockquote)
,
tags:
%w(table a figure img figcaption i em b strong
p
h2 h3 h4 h5 h6 blockquote)
,
attributes:
%w(href alt title target rel src srcset width height)
text
.
gsub!
"
\r
"
,
''
text
.
gsub!
"
\n
"
,
' '
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website/imported/post.rb
+
22
−
3
View file @
42e23f9e
...
...
@@ -91,9 +91,28 @@ class Communication::Website::Imported::Post < ApplicationRecord
post
.
updated_at
=
updated_at
post
.
published_at
=
published_at
if
published_at
post
.
published
=
true
if
featured_medium
.
nil?
# Use first image in text as featured medium
end
post
.
save
download_first_image_as_featured_image
if
featured_medium
.
nil?
end
# Please refactor me i'm ugly
def
download_first_image_as_featured_image
doc
=
Nokogiri
::
HTML
(
post
.
text
.
to_s
)
images
=
doc
.
css
(
'img'
)
if
images
.
any?
url
=
images
.
first
.
attr
(
'src'
)
uri
=
URI
(
url
)
filename
=
File
.
basename
url
http
=
Net
::
HTTP
.
new
(
uri
.
host
,
uri
.
port
)
http
.
use_ssl
=
true
http
.
verify_mode
=
OpenSSL
::
SSL
::
VERIFY_NONE
request
=
Net
::
HTTP
::
Get
.
new
(
uri
.
request_uri
)
response
=
http
.
request
(
request
)
begin
post
.
featured_image
.
attach
(
io:
StringIO
.
new
(
response
.
body
),
filename:
filename
,
content_type:
'image/jpeg'
)
ensure
tempfile
.
close!
end
end
end
end
This diff is collapsed.
Click to expand it.
config/locales/fr.yml
+
7
−
0
View file @
42e23f9e
...
...
@@ -120,3 +120,10 @@ fr:
terms_of_service_url
:
https://osuny.org/conditions-d-utilisation
true
:
Oui
validate
:
Valider
views
:
pagination
:
first
:
"
«
Premier"
last
:
"
Dernier
»"
previous
:
"
‹
Précédent"
next
:
"
Suivant
›"
truncate
:
"
…"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment