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
f8130a0e
Unverified
Commit
f8130a0e
authored
3 years ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
blob handled in github file
parent
2cc89724
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/github_file.rb
+20
-2
20 additions, 2 deletions
app/models/communication/website/github_file.rb
app/models/communication/website/with_publishable_objects.rb
+0
-21
0 additions, 21 deletions
app/models/communication/website/with_publishable_objects.rb
with
20 additions
and
23 deletions
app/models/communication/website/github_file.rb
+
20
−
2
View file @
f8130a0e
...
...
@@ -78,7 +78,17 @@ class Communication::Website::GithubFile < ApplicationRecord
def
remove_from_github
return
unless
github
.
valid?
github
.
remove
(
github_path
,
github_remove_commit_message
)
github
.
remove
github_path
,
github_remove_commit_message
remove_media_from_github
end
def
remove_media_from_github
return
unless
about
.
respond_to?
(
:active_storage_blobs
)
about
.
active_storage_blobs
.
each
{
|
blob
|
remove_blob_from_github
(
blob
)
}
end
def
remove_blob_from_github
(
blob
)
github
.
remove
github_blob_path
(
blob
),
github_blob_remove_commit_message
end
def
github
...
...
@@ -96,7 +106,7 @@ class Communication::Website::GithubFile < ApplicationRecord
def
github_blob_params
(
blob
)
blob
.
analyze
unless
blob
.
analyzed?
{
path:
"_data/media/
#{
blob
.
id
[
0
..
1
]
}
/
#{
blob
.
id
}
.yml"
,
path:
github_blob_path
(
blob
)
,
data:
ApplicationController
.
render
(
template:
'active_storage/blobs/jekyll'
,
layout:
false
,
...
...
@@ -105,6 +115,10 @@ class Communication::Website::GithubFile < ApplicationRecord
}
end
def
github_blob_path
(
blob
)
"_data/media/
#{
blob
.
id
[
0
..
1
]
}
/
#{
blob
.
id
}
.yml"
end
def
github_commit_message
"[
#{
about
.
class
.
name
.
demodulize
}
] Save
#{
about
.
to_s
}
"
end
...
...
@@ -116,4 +130,8 @@ class Communication::Website::GithubFile < ApplicationRecord
def
github_remove_commit_message
"[
#{
about
.
class
.
name
.
demodulize
}
] Remove
#{
about
.
to_s
}
"
end
def
github_blob_remove_commit_message
(
blob
)
"[Medium] Remove #
#{
blob
.
id
}
"
end
end
This diff is collapsed.
Click to expand it.
app/models/communication/website/with_publishable_objects.rb
+
0
−
21
View file @
f8130a0e
...
...
@@ -2,32 +2,11 @@ module Communication::Website::WithPublishableObjects
extend
ActiveSupport
::
Concern
included
do
def
publish_about_object
# TODO: Handle Research::Journal then use the commented version.
# about.force_publish! unless about.nil?
about
.
force_publish!
if
about
.
is_a?
(
Education
::
School
)
end
def
publish_blob
(
blob
)
return
unless
github
.
valid?
blob
.
analyze
unless
blob
.
analyzed?
github_path
=
"_data/media/
#{
blob
.
id
[
0
..
1
]
}
/
#{
blob
.
id
}
.yml"
github_commit_message
=
"[Medium] Save #
#{
blob
.
id
}
"
data
=
ApplicationController
.
render
(
template:
'active_storage/blobs/jekyll'
,
layout:
false
,
assigns:
{
blob:
blob
}
)
github
.
publish
(
path:
github_path
,
commit:
github_commit_message
,
data:
data
)
end
handle_asynchronously
:publish_blob
,
queue:
'default'
def
remove_blob
(
blob
)
return
unless
github
.
valid?
github_path
=
"_data/media/
#{
blob
.
id
[
0
..
1
]
}
/
#{
blob
.
id
}
.yml"
github_commit_message
=
"[Medium] Remove #
#{
blob
.
id
}
"
github
.
remove
(
github_path
,
github_commit_message
)
end
end
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