-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add endpoint for solution image generator (#5747)
* Add endpoint for solution image generator * Allow access from docker --------- Co-authored-by: Erik Schierboom <[email protected]>
- Loading branch information
1 parent
176fe73
commit db86b3c
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module SPI | ||
class SolutionImageDataController < BaseController | ||
def show | ||
solution = Solution.for!( | ||
params[:user_handle], | ||
params[:track_slug], | ||
params[:exercise_slug] | ||
) | ||
|
||
exercise = solution.exercise | ||
track = exercise.track | ||
file = solution.latest_published_iteration_submission.files.first | ||
snippet = solution.snippet.presence || file.content[0, 10] | ||
render json: { | ||
solution: { | ||
snippet:, | ||
extension: File.extname(file.filename), | ||
language: track.highlightjs_language, | ||
track_icon_url: track.icon_url, | ||
exercise_icon_url: exercise.icon_url, | ||
user_avatar_url: solution.user.avatar_url | ||
} | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters