Skip to content
Permalink
Browse files

Improved layout of collection

  • Loading branch information...
Thoulah committed Mar 6, 2019
1 parent d5856e0 commit 019e7877214d94dca266631fbc246f7b41fd8c45

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -82,12 +82,6 @@ svg.fa {
}
}

&music-collection {
.card {
min-width: 9rem;
}
}

&lyrics {
.artists {
font-weight: $font-weight-bold;
@@ -5,6 +5,7 @@
use yii\bootstrap4\Html;
use yii\filters\{AccessControl, AjaxFilter, VerbFilter};
use yii\helpers\Url;
use yii\web\Response;
use yii\web\{MethodNotAllowedHttpException, NotFoundHttpException, UnauthorizedHttpException};
class ArticlesController extends \yii\web\Controller {
@@ -63,7 +64,7 @@ public function actionArticle(int $id, string $title = ''): string {
]);
}
public function actionPdf(int $id, string $title): void {
public function actionPdf(int $id, string $title): Response {
$model = Articles::find()
->where(['id' => $id])
->one();
@@ -75,7 +76,7 @@ public function actionPdf(int $id, string $title): void {
$this->redirect(['pdf', 'id' => $model->id, 'title' => $model->url], 301)->send();
$fileName = Articles::buildPdf($model);
Yii::$app->response->sendFile($fileName, implode(' - ', [Yii::$app->name, $model->url]).'.pdf');
return Yii::$app->response->sendFile($fileName, implode(' - ', [Yii::$app->name, $model->url]).'.pdf');
}
public function actionCreate(): string {
@@ -8,14 +8,13 @@
class FeedController extends \yii\web\Controller {
public function behaviors(): array {
$lastModified = Articles::getLastModified();
return [
[
'class' => HttpCache::class,
'enabled' => !YII_DEBUG,
'except' => ['index'],
'etagSeed' => function() { return serialize([phpversion(), Yii::$app->user->id, $lastModified]); },
'lastModified' => function() { return $lastModified; },
'etagSeed' => function() { return serialize([phpversion(), Yii::$app->user->id, Articles::getLastModified()]); },
'lastModified' => function() { return Articles::getLastModified(); },
'only' => ['rss', 'sitemap-articles'],
],
];
@@ -10,9 +10,8 @@ class WebhookController extends \yii\web\Controller {
public function actionGithub(): array {
Yii::$app->response->format = Response::FORMAT_JSON;
[$algo, $hash] = explode('=', Yii::$app->request->headers->get('X-Hub-Signature', 'sha512=1'), 2);
if (!hash_equals($hash, hash_hmac($algo, file_get_contents('php://input'), Yii::$app->params['secrets']['github']['hook']))) :
if (!hash_equals($hash, hash_hmac($algo, file_get_contents('php://input'), Yii::$app->params['secrets']['github']['hook'])))
throw new UnauthorizedHttpException('Access denied!');
endif;
$github = new Github();
switch (Yii::$app->request->headers->get('X-GitHub-Event')) :
@@ -10,12 +10,17 @@ public function testFeedController() {
$this->assertContains('</urlset>', \Yii::$app->runAction('feed/sitemap-lyrics'));
}
public function testLyricsController() {
public function testArticlesController() {
$this->assertInstanceOf(\yii\web\Response::class, \Yii::$app->runAction('articles/pdf', ['id' => 4, 'title' => 'Markdown Syntax']));
}
public function testMusicController() {
$this->assertContains('Nórdika', \Yii::$app->runAction('music/lyrics'));
$_GET = ['artist' => 'Nordika'];
$this->assertContains('Ecstasy', \Yii::$app->runAction('music/lyrics'));
$_GET = ['artist' => 'Nordika', 'year' => 2017, 'album' => 'Ecstasy'];
$this->assertContains('In oblivion…', \Yii::$app->runAction('music/lyrics'));
$this->assertInstanceOf(\yii\web\Response::class, \Yii::$app->runAction('music/albumpdf'));
}
public function testSiteController() {
@@ -28,7 +28,7 @@
echo Html::tag('div', $comment->parsedContent, ['class' => 'card-body']);
echo Html::beginTag('div', ['class' => 'card-footer']);
if (!is_null($comment->user)) :
if ($comment->user !== null) :
$user = User::find(['id' => $comment->user])->with('profile')->one();
$comment->name = $user->profile->name ?? $user->username;
$comment->website = $user->profile->website;
@@ -24,18 +24,18 @@
echo Html::beginTag('div', ['class' => 'tab-content']);
foreach ($tabs as $tab => $tabdesc) :
echo Html::beginTag('div', ['aria-labelledby' => "{$tab}-tab", 'class' => ($tab === array_key_first($tabs)) ? 'tab-pane fade show active' : 'tab-pane fade', 'id' => $tab, 'role' => 'tabpanel']);
echo Html::beginTag('div', ['class' => 'site-music-collection']);
echo Html::beginTag('div', ['class' => 'card-deck']);
foreach ($model->find()->where(['user_id' => 1, 'status' => $tab])->orderBy(['artist' => SORT_ASC, 'year' => SORT_ASC])->all() as $album) :
echo Html::beginTag('div', ['class' => 'card mb-3']);
echo Html::beginTag('div', ['class' => 'row justify-content-center']);
foreach ($model->find()->where(['user_id' => 1, 'status' => $tab])->orderBy(['artist' => SORT_ASC, 'year' => SORT_ASC])->all() as $album) :
echo Html::beginTag('div', ['class' => 'col-12 col-sm-6 col-md-3 col-xl-2 mt-3']);
echo Html::beginTag('div', ['class' => 'card']);
echo Html::a(
Html::img("@assets/images/blank.png", ['alt' => "{$album->artist} - {$album->year} - {$album->title}", 'class' => 'card-img-top rounded', 'data-src' => Url::to(['music/collection-cover', 'id' => $album->id])])
, "https://www.discogs.com/release/{$album->id}");
echo Html::tag('div', Html::tag('small', $album->title, ['class' => 'card-text mt-auto mx-auto font-weight-bold notranslate']), ['class' => 'card-body d-flex text-center p-2']);
echo Html::tag('div', Html::tag('small', $album->artist), ['class' => 'card-footer text-center p-2 notranslate']);
echo Html::endTag('div');
endforeach;
echo Html::endTag('div');
echo Html::endTag('div');
endforeach;
echo Html::endTag('div');
echo Html::endTag('div');
endforeach;
@@ -6,7 +6,7 @@
use yii\widgets\Pjax;
$this->title = Yii::t('mr42', 'Contact');
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'] = [$this->title];
Form::charCount($this, $model->rules()['charCount']['max']);
$this->registerJs("var inputFile = {lang:{selected:'".Yii::t('mr42', 'File {name} Selected', ['name' => Html::tag('span', null, ['class' => 'filename'])])."'}};".Yii::$app->formatter->jspack('inputFile.js'), View::POS_READY);
@@ -2,7 +2,7 @@
use yii\helpers\{Html, Inflector};
$this->title = 'PHP '.phpversion();
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'] = [$this->title];
echo Html::tag('h1', $this->title);
@@ -3,7 +3,7 @@
use yii\web\View;
$this->title = Yii::t('mr42', 'My Pi');
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'] = [$this->title];
$tabs = [
'day' => ['short' => Yii::t('mr42', 'Day'), 'long' => Yii::t('mr42', 'Last Day')],
@@ -3,7 +3,7 @@
use yii\helpers\Url;
$this->title = Yii::t('mr42', 'Privacy Policy');
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'] = [$this->title];
echo Html::tag('h1', $this->title);
@@ -23,7 +23,7 @@ public function actionPhp($version) {
$a->addFile(Yii::getAlias("@webroot/../../../bin/lib/{$file}"), "bin/lib/{$file}");
endforeach;
$a->convertToData(Phar::TAR, Phar::BZ2);
unlink($archiveFile);
FileHelper::unlink($archiveFile);
Yii::$app->response->sendFile($compressedFile, "php{$version}.tar.bz2");
}

0 comments on commit 019e787

Please sign in to comment.
You can’t perform that action at this time.