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
220e9d49
Unverified
Commit
220e9d49
authored
3 years ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
without conern
parent
7f024ef4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website/imported/page.rb
+18
-3
18 additions, 3 deletions
app/models/communication/website/imported/page.rb
app/models/communication/website/imported/post.rb
+18
-3
18 additions, 3 deletions
app/models/communication/website/imported/post.rb
with
36 additions
and
6 deletions
app/models/communication/website/imported/page.rb
+
18
−
3
View file @
220e9d49
...
...
@@ -36,7 +36,6 @@
# fk_rails_... (website_id => communication_website_imported_websites.id)
#
class
Communication::Website::Imported::Page
<
ApplicationRecord
include
Communication
::
Website
::
Imported
::
WithFeaturedImage
include
Communication
::
Website
::
Imported
::
WithRichText
belongs_to
:university
...
...
@@ -94,9 +93,25 @@ class Communication::Website::Imported::Page < ApplicationRecord
page
.
published
=
true
page
.
save
if
featured_medium
.
present?
download_featured_medium_file_as_featured_image
(
page
)
featured_medium
.
load_remote_file!
unless
featured_medium
.
file
.
attached?
page
.
featured_image
.
attach
(
io:
URI
.
open
(
featured_medium
.
file
.
blob
.
url
),
filename:
featured_medium
.
file
.
blob
.
filename
,
content_type:
featured_medium
.
file
.
blob
.
content_type
)
else
download_first_image_in_text_as_featured_image
(
page
)
fragment
=
Nokogiri
::
HTML
.
fragment
(
page
.
text
.
to_s
)
image
=
fragment
.
css
(
'img'
).
first
if
image
.
present?
begin
url
=
image
.
attr
(
'src'
)
download_service
=
DownloadService
.
download
(
url
)
page
.
featured_image
.
attach
(
download_service
.
attachable_data
)
image
.
remove
page
.
update
(
text:
fragment
.
to_html
)
rescue
end
end
end
page
.
update
(
text:
rich_text_with_attachments
(
page
.
text
.
to_s
))
end
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website/imported/post.rb
+
18
−
3
View file @
220e9d49
...
...
@@ -35,7 +35,6 @@
# fk_rails_... (website_id => communication_website_imported_websites.id)
#
class
Communication::Website::Imported::Post
<
ApplicationRecord
include
Communication
::
Website
::
Imported
::
WithFeaturedImage
include
Communication
::
Website
::
Imported
::
WithRichText
belongs_to
:university
...
...
@@ -96,9 +95,25 @@ class Communication::Website::Imported::Post < ApplicationRecord
post
.
published
=
true
post
.
save
if
featured_medium
.
present?
download_featured_medium_file_as_featured_image
(
post
)
featured_medium
.
load_remote_file!
unless
featured_medium
.
file
.
attached?
post
.
featured_image
.
attach
(
io:
URI
.
open
(
featured_medium
.
file
.
blob
.
url
),
filename:
featured_medium
.
file
.
blob
.
filename
,
content_type:
featured_medium
.
file
.
blob
.
content_type
)
else
download_first_image_in_text_as_featured_image
(
post
)
fragment
=
Nokogiri
::
HTML
.
fragment
(
post
.
text
.
to_s
)
image
=
fragment
.
css
(
'img'
).
first
if
image
.
present?
begin
url
=
image
.
attr
(
'src'
)
download_service
=
DownloadService
.
download
(
url
)
post
.
featured_image
.
attach
(
download_service
.
attachable_data
)
image
.
remove
post
.
update
(
text:
fragment
.
to_html
)
rescue
end
end
end
post
.
update
(
text:
rich_text_with_attachments
(
post
.
text
.
to_s
))
end
...
...
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