Skip to content

Commit

Permalink
rendered scores for externals in api
Browse files Browse the repository at this point in the history
  • Loading branch information
thes01 committed Feb 12, 2024
1 parent 03bdc1e commit c9d390e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
18 changes: 15 additions & 3 deletions app/RenderedScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Services\RenderedScoreService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;

class RenderedScore extends Model
{
Expand Down Expand Up @@ -46,9 +47,20 @@ public function scopeSvg($query)
return $query->where('filetype', 'svg');
}

public function getPublicUrlPrefixAttribute()
public function getPublicUrlAttribute()
{
// this is actually served by nginx
return url("/rendered_scores/$this->filename");
// this should actually be served by nginx
return url("/$this->filepath");
}

public function getFilepathAttribute()
{
return "rendered_scores/$this->filename.$this->filetype";
}

public function getContentsAttribute()
{
$path = Storage::path($this->filepath);
return file_get_contents($path);
}
}
5 changes: 5 additions & 0 deletions app/SongLyric.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ public function lilypond_rendered_scores(): HasManyThrough
return $this->hasManyThrough(RenderedScore::class, LilypondPartsSheetMusic::class, null, 'lilypond_parts_sheet_music_id');
}

public function external_rendered_scores(): HasManyThrough
{
return $this->hasManyThrough(RenderedScore::class, External::class, null, 'external_id');
}

// -----------

public function arrangements(): HasMany
Expand Down
7 changes: 5 additions & 2 deletions graphql/rendered_score.graphql
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
type LilypondRenderedScore {
type RenderedScore {
id: Int
filename: String
filetype: String
frontend_display_order: Int
public_url_prefix: String

public_url: String
contents: String

render_config: RenderConfig
secondary_filetypes: [String]

lilypond_parts_sheet_music: LilypondPartsSheetMusic
external: External
}

type RenderConfig {
Expand Down
4 changes: 3 additions & 1 deletion graphql/song_lyric.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ type SongLyric {
lilypond_rendered_scores(
filetype: String @eq
wide: Boolean @scope(name: "wide")
): [LilypondRenderedScore] @hasMany
): [RenderedScore] @hasMany

external_rendered_scores: [RenderedScore] @hasMany

lilypond_key_major: String
type_enum: SongType @rename(attribute: "type")
Expand Down

0 comments on commit c9d390e

Please sign in to comment.