use Notion\Pages\Properties\Title;
-class FrontController extends Controller {
+class FrontController extends Controller
+{
public static $notionFileFields = [
'demos' => ['notion' => 'Démos Voix', 'cat' => '🎤 Démos'],
'instru' => ['notion' => 'Instru', 'cat' => '🎸 Instru'],
'archives' => ['notion' => 'Archives et autres fichiers', 'cat' => '🗃️ Archives']
];
- public static function defaultCollection() {
+ public static function defaultCollection()
+ {
return redirect('/' . Collection::withoutGlobalScope('ownerclause')->find(1)->slug);
}
- public function collection($name) {
+ public function collection($name)
+ {
$collection = Collection::withoutGlobalScope('ownerclause')->where('slug', $name)->first();
if (null === $collection) {
return self::defaultCollection();
return $this->notionCollection($collection);
}
- $lists = CollectionList::withoutGlobalScope('ownerclause')->where('collection', $collection->id)->orderBy('id','desc')->get();
+ $lists = CollectionList::withoutGlobalScope('ownerclause')->where('collection', $collection->id)->orderBy('order_num', 'DESC')->orderBy('id', 'DESC')->get();
$songs = $this->_getSongsOfCollection($collection->id, $lists);
return view('collection', ['menu' => true, 'songs' => $songs, 'collection' => $collection, 'collection_songs' => $songs, 'collection_lists' => $lists]);
/**
* @throws \Exception
*/
- public function notionCollection($collection) {
+ public function notionCollection($collection)
+ {
$songs = self::getSongsOfNotionCollection($collection);
return view('notion_collection', ['menu' => true, 'notion' => true, 'songs' => $songs, 'collection' => $collection, 'collection_songs' => $songs]);
}
- public function checkPassword(Collection $collection) {
+ public function checkPassword(Collection $collection)
+ {
if (!$collection->password) {
return false;
}
return view('login', ['menu' => false, 'collection' => $collection, 'error' => $error]);
}
- public function song($collection, $song) {
+ public function song($collection, $song)
+ {
/** @var Collection $collection */
$collection = Collection::withoutGlobalScope('ownerclause')->where('slug', $collection)->first();
if (null === $collection) {
}
- $lists = CollectionList::withoutGlobalScope('ownerclause')->where('collection', $collection->id)->orderBy('id','desc')->get();
+ $lists = CollectionList::withoutGlobalScope('ownerclause')->where('collection', $collection->id)->orderBy('id', 'desc')->get();
$partition = false;
$lyrics_html = '';
return view('song', ['menu' => true, 'lyrics_html' => $lyrics_html, 'song' => $song, 'collection' => $collection, 'partition' => $partition, 'collection_songs' => $this->_getSongsOfCollection($collection->id, $lists), 'collection_lists' => $lists]);
}
- protected function notionSong($collection, $song) {
+ protected function notionSong($collection, $song)
+ {
$partition = false;
$u = $song . '.html';
return view('notion_song', ['menu' => true, 'notion' => true, 'lyrics_html' => $lyrics_html, 'song' => $song, 'collection' => $collection, 'collection_songs' => $songs]);
}
- protected function _getSongsOfCollection($id, $lists) {
+ protected function _getSongsOfCollection($id, $lists)
+ {
/** @var Song $q */
$q = Song::withoutGlobalScope('ownerclause')->whereRaw('json_contains(collections, \'["' . $id . '"]\')');
foreach ($lists as $list) {
* @return \App\Notion\Song[]
* @throws \Exception
*/
- public static function getSongsOfNotionCollection($collection, $force = false) {
+ public static function getSongsOfNotionCollection($collection, $force = false)
+ {
$cacheKey = 'songs_notion_' . $collection->notion_database . '_' . $collection->id;
$ttl = 900;
if ($force) {
}
- protected static function _getSongsOfNotionCollection($collection) {
+ protected static function _getSongsOfNotionCollection($collection)
+ {
$audios = ['mp3', 'm4a', 'wav'];
$notion = Notion::create($collection->notion_key);
* @param $block RichTextProperty|BlockInterface
* @return string
*/
- protected static function _blockToHtml($block) {
+ protected static function _blockToHtml($block)
+ {
$start = '<p>';
$end = '</p>';
if ($block instanceof Paragraph) {
* @param $rt RichText
* @return string
*/
- protected static function _richTextToHtml($rt) {
+ protected static function _richTextToHtml($rt)
+ {
$start = '';
$end = '';
return $start . nl2br($rt->plainText) . $end;
}
- public static function parseFileNameFromAmazonURL($url) {
+ public static function parseFileNameFromAmazonURL($url)
+ {
$u = parse_url($url);
$p = explode('/', $u['path']);
$f = array_pop($p);
return str_replace('_', ' ', $f);
}
- public static function parseExtensionFromAmazonURL($url) {
+ public static function parseExtensionFromAmazonURL($url)
+ {
$u = parse_url($url);
$p = explode('/', $u['path']);
$f = array_pop($p);
return array_pop($e);
}
- public function manifest($collection) {
+ public function manifest($collection)
+ {
$collection = Collection::withoutGlobalScope('ownerclause')->where('slug', $collection)->first();
if (null === $collection) {
abort(404);
$icons[count($icons) - 1]['purpose'] = 'maskable';
$res = ['name' => $collection->name,
- 'short_name' => $collection->shortname ?: $collection->name,
- 'description' => '',
- 'display' => 'standalone',
- 'orientation' => 'any',
- 'background_color' => $collection->splashscreen_color,
- 'theme_color' => $collection->theme_color,
- 'start_url' => '/' . $collection->slug,
- 'scope' => '/' . $collection->slug,
- 'icons' => $icons];
+ 'short_name' => $collection->shortname ?: $collection->name,
+ 'description' => '',
+ 'display' => 'standalone',
+ 'orientation' => 'any',
+ 'background_color' => $collection->splashscreen_color,
+ 'theme_color' => $collection->theme_color,
+ 'start_url' => '/' . $collection->slug,
+ 'scope' => '/' . $collection->slug,
+ 'icons' => $icons];
return response(json_encode($res))->header('Content-Type', 'application/manifest+json');
}
- public function downloadAssets($songId) {
+ public function downloadAssets($songId)
+ {
/** @var Song $song */
$song = Song::withoutGlobalScope('ownerclause')->find($songId);
$fields = ['partition', 'lyrics_doc'];