Skip to content

Commit c146bf1

Browse files
authored
feat. add theme-color and twitter metas, move metas inro elements folder (#294)
1 parent 90f14dd commit c146bf1

11 files changed

Lines changed: 113 additions & 33 deletions

File tree

app/Config/Schema/schema.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ class AppSchema extends CakeSchema
238238
'description' => ['type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
239239
'favicon_url' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
240240
'img_url' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
241+
'theme_color' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
242+
'twitter_site' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
241243
'page' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'],
242244
'indexes' => [
243245
'PRIMARY' => ['column' => 'id', 'unique' => 1]

app/Controller/AppController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ public function __initSeoConfiguration()
546546
$seo_config['favicon_url'] = Router::url($seo_config['favicon_url'], true);
547547
$seo_config['img_url'] = (empty($seo_config['img_url']) ? $seo_config['favicon_url'] : Router::url($seo_config['img_url'], true));
548548
$seo_config['title'] = str_replace(["{TITLE}", "{WEBSITE_NAME}"], [(!empty($this->viewVars['title_for_layout']) ? $this->viewVars['title_for_layout'] : $this->Lang->get("GLOBAL__ERROR")), (!empty($this->viewVars['website_name']) ? $this->viewVars['website_name'] : "MineWeb")], $seo_config['title']);
549+
$seo_config['theme_color'] = (!empty($get_page['Seo']['theme_color']) ? $get_page['Seo']['theme_color'] : (!empty($default['Seo']['theme_color']) ? $default['Seo']['theme_color'] : ""));
550+
$seo_config['twitter_site'] = (!empty($get_page['Seo']['twitter_site']) ? $get_page['Seo']['twitter_site'] : (!empty($default['Seo']['twitter_site']) ? $default['Seo']['twitter_site'] : ""));
549551
$this->set(compact('seo_config'));
550552
}
551553

app/View/Elements/seo.ctp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<title><?= $seo_config['title'] ?></title>
2+
<link rel="icon" type="image/png" href="<?= $seo_config['favicon_url'] ?>"/>
3+
<meta name="title" content="<?= $seo_config['title'] ?>">
4+
<meta property="og:title" content="<?= $seo_config['title'] ?>">
5+
<meta name="description" content="<?= $seo_config['description'] ?>">
6+
<meta property="og:description" content="<?= $seo_config['description'] ?>">
7+
<meta property="og:image" content="<?= $seo_config['img_url'] ?>">
8+
<meta name="theme-color" content="<?= $seo_config['theme_color'] ?>">
9+
<meta name="twitter:card" content="summary" />
10+
<meta name="twitter:site" content="<?= $seo_config['twitter_site'] ?>" />

app/View/Layouts/default.ctp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@
77
<meta http-equiv="X-UA-Compatible" content="IE=edge">
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<meta name="author" content="Eywek">
10-
11-
<title><?= $seo_config['title'] ?></title>
12-
<link rel="icon" type="image/png" href="<?= $seo_config['favicon_url'] ?>"/>
13-
<meta name="title" content="<?= $seo_config['title'] ?>">
14-
<meta property="og:title" content="<?= $seo_config['title'] ?>">
15-
<meta name="description" content="<?= $seo_config['description'] ?>">
16-
<meta property="og:description" content="<?= $seo_config['description'] ?>">
17-
<meta property="og:image" content="<?= $seo_config['img_url'] ?>">
10+
11+
<?= $this->element('seo') ?>
1812

1913
<!-- Font Awesome 5 -->
2014
<script src="https://kit.fontawesome.com/fb032ab5a6.js" crossorigin="anonymous"></script>

app/View/Seo/admin_add.ctp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,44 @@
4343

4444
<div class="col-sm-6">
4545
<div class="form-group">
46-
<em><?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
46+
<label><?= $Lang->get('SEO__FORM_FAVICON') ?></label><em> <?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
4747
<br>
4848
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
49-
<?= $this->element('form.input.upload.img', ['filename' => "favicon.png", 'title' => $Lang->get('SEO__FORM_FAVICON')]); ?>
49+
<?= $this->element('form.input.upload.img', ['filename' => "favicon.png"]); ?>
5050
</div>
5151
</div>
5252
<div class="col-sm-6">
5353
<div class="form-group">
54-
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label>
55-
<em><?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
54+
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label><em> <?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
5655
<br>
5756
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
5857
<input type="text" class="form-control" name="img_url">
5958
</div>
6059
</div>
60+
61+
<div class="col-12">
62+
<hr>
63+
</div>
64+
65+
<div class="col-sm-6">
66+
<div class="form-group">
67+
<label><?= $Lang->get('SEO__FORM_THEME_COLOR') ?></label><em> <?= $Lang->get('SEO__FORM_THEME_COLOR_DESC') ?></em>
68+
<br>
69+
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
70+
<input type="color" class="form-control" name="theme_color">
71+
</div>
72+
</div>
73+
<div class="col-sm-6">
74+
<div class="form-group">
75+
<label><?= $Lang->get('SEO__FORM_TWITTER_SITE') ?></label><em> <?= $Lang->get('SEO__FORM_TWITTER_SITE_DESC') ?></em>
76+
<br>
77+
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
78+
<input type="text" class="form-control" name="twitter_site">
79+
</div>
80+
</div>
6181
</div>
6282

83+
6384
<div class="float-right">
6485
<a href="<?= $this->Html->url(['controller' => 'seo', 'action' => 'index', 'admin' => true]) ?>"
6586
class="btn btn-default"><?= $Lang->get('GLOBAL__CANCEL') ?></a>

app/View/Seo/admin_edit.ctp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,42 @@
4646

4747
<div class="col-sm-6">
4848
<div class="form-group">
49-
<em><?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
49+
<label><?= $Lang->get('SEO__FORM_FAVICON') ?></label><em> <?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
5050
<br>
5151
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
52-
<?= $this->element('form.input.upload.img', ['img' => $page['favicon_url'], 'filename' => "favicon.png", 'title' => $Lang->get('SEO__FORM_FAVICON')]); ?>
52+
<?= $this->element('form.input.upload.img', ['img' => $page['favicon_url'], 'filename' => "favicon.png"]); ?>
5353
</div>
5454
</div>
5555
<div class="col-sm-6">
5656
<div class="form-group">
57-
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label>
58-
<em><?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
57+
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label><em> <?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
5958
<br>
6059
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
61-
<input type="text" class="form-control" value="<?= $page['img_url'] ?>"
60+
<input type="text" class="form-control" value="<?= $page['img_url'] ?>"
6261
name="img_url">
6362
</div>
6463
</div>
64+
65+
<div class="col-12">
66+
<hr>
67+
</div>
68+
69+
<div class="col-sm-6">
70+
<div class="form-group">
71+
<label><?= $Lang->get('SEO__FORM_THEME_COLOR') ?></label><em> <?= $Lang->get('SEO__FORM_THEME_COLOR_DESC') ?></em>
72+
<br>
73+
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
74+
<input type="color" class="form-control" value="<?= $page['theme_color'] ?>" name="theme_color">
75+
</div>
76+
</div>
77+
<div class="col-sm-6">
78+
<div class="form-group">
79+
<label><?= $Lang->get('SEO__FORM_TWITTER_SITE') ?></label> <em><?= $Lang->get('SEO__FORM_TWITTER_SITE_DESC') ?></em>
80+
<br>
81+
<em><?= $Lang->get('SEO__KEEP_EMPTY') ?></em>
82+
<input type="text" class="form-control" value="<?= $page['twitter_site'] ?>" name="twitter_site">
83+
</div>
84+
</div>
6585
</div>
6686

6787
<div class="float-right">

app/View/Seo/admin_index.ctp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,37 @@
3838

3939
<div class="col-sm-6">
4040
<div class="form-group">
41-
<em><?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
42-
<?= $this->element('form.input.upload.img', ['img' => isset($default['favicon_url']) ? $default['favicon_url'] : "", 'filename' => "favicon.png", 'title' => $Lang->get('SEO__FORM_FAVICON')]); ?>
41+
<label><?= $Lang->get('SEO__FORM_FAVICON') ?></label><em> <?= $Lang->get('SEO__FORM_FAVICON_DESC') ?></em>
42+
<?= $this->element('form.input.upload.img', ['img' => isset($default['favicon_url']) ? $default['favicon_url'] : "", 'filename' => "favicon.png"]); ?>
4343
</div>
4444
</div>
4545
<div class="col-sm-6">
4646
<div class="form-group">
47-
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label>
48-
<em><?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
49-
<input type="text" class="form-control" value="<?= isset($default['img_url']) ? $default['img_url'] : "" ?>"
50-
name="img_url">
47+
<label><?= $Lang->get('SEO__FORM_IMG_URL') ?></label><em> <?= $Lang->get('SEO__FORM_IMG_URL_DESC') ?></em>
48+
<input type="text" class="form-control" value="<?= isset($default['img_url']) ? $default['img_url'] : "" ?>" name="img_url">
5149
</div>
5250
</div>
51+
52+
<div class="col-12">
53+
<hr>
54+
</div>
55+
56+
<div class="col-sm-6">
57+
<div class="form-group">
58+
<label><?= $Lang->get('SEO__FORM_THEME_COLOR') ?></label><em> <?= $Lang->get('SEO__FORM_THEME_COLOR_DESC') ?></em>
59+
<input type="color" class="form-control" value="<?= isset($default['theme_color']) ? $default['theme_color'] : "" ?>" name="theme_color">
60+
</div>
61+
</div>
62+
<div class="col-sm-6">
63+
<div class="form-group">
64+
<label><?= $Lang->get('SEO__FORM_TWITTER_SITE') ?></label><em> <?= $Lang->get('SEO__FORM_TWITTER_SITE_DESC') ?></em>
65+
<input type="text" class="form-control" value="<?= isset($default['twitter_site']) ? $default['twitter_site'] : "" ?>" name="twitter_site">
66+
</div>
67+
</div>
68+
5369
</div>
5470

55-
<button class="btn btn-primary float-right"
56-
type="submit"><?= $Lang->get('GLOBAL__SUBMIT') ?></button>
71+
<button class="btn btn-primary float-right" type="submit"><?= $Lang->get('GLOBAL__SUBMIT') ?></button>
5772

5873
</form>
5974

lang/en_UK.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,13 @@
328328
"SEO__FORM_TITLE_DESC_W": "Site name in general settings",
329329
"SEO__FORM_DESCRIPTION": "Description",
330330
"SEO__FORM_FAVICON": "Favicon",
331-
"SEO__FORM_FAVICON_DESC": " (Small icon in the browser bar)",
331+
"SEO__FORM_FAVICON_DESC": "(Small icon in the browser bar)",
332332
"SEO__FORM_IMG_URL": "Image url",
333-
"SEO__FORM_IMG_URL_DESC": " (For Discord, Facebook, Twitter ...) Leave blank to use the favicon instead",
333+
"SEO__FORM_IMG_URL_DESC": "(For Discord, Facebook, Twitter ...) Leave blank to use the favicon instead",
334+
"SEO__FORM_THEME_COLOR": "Theme color",
335+
"SEO__FORM_THEME_COLOR_DESC": "(For the embed discord for example)",
336+
"SEO__FORM_TWITTER_SITE": "Twitter tag",
337+
"SEO__FORM_TWITTER_SITE_DESC": "(From your server for example)",
334338
"SEO__ADD_PAGE": "Add a Page",
335339
"SEO__EDIT_PAGE": "Edit a Page",
336340
"SEO__EDIT_SUCCESS": "SEO information edited successfully",

lang/en_US.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,13 @@
329329
"SEO__FORM_TITLE_DESC_W": "Site name in general settings",
330330
"SEO__FORM_DESCRIPTION": "Description",
331331
"SEO__FORM_FAVICON": "Favicon",
332-
"SEO__FORM_FAVICON_DESC": " (Small icon in the browser bar)",
332+
"SEO__FORM_FAVICON_DESC": "(Small icon in the browser bar)",
333333
"SEO__FORM_IMG_URL": "Image url",
334-
"SEO__FORM_IMG_URL_DESC": " (For Discord, Facebook, Twitter ...) Leave blank to use the favicon instead",
334+
"SEO__FORM_IMG_URL_DESC": "(For Discord, Facebook, Twitter ...) Leave blank to use the favicon instead",
335+
"SEO__FORM_THEME_COLOR": "Theme color",
336+
"SEO__FORM_THEME_COLOR_DESC": "(For the embed discord for example)",
337+
"SEO__FORM_TWITTER_SITE": "Twitter tag",
338+
"SEO__FORM_TWITTER_SITE_DESC": "(From your server for example)",
335339
"SEO__ADD_PAGE": "Add a Page",
336340
"SEO__EDIT_PAGE": "Edit a Page",
337341
"SEO__EDIT_SUCCESS": "SEO information edited successfully",

lang/fr_FR.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,13 @@
330330
"SEO__FORM_TITLE_DESC_W": "Nom du site dans les paramètres généraux",
331331
"SEO__FORM_DESCRIPTION": "Description",
332332
"SEO__FORM_FAVICON": "Favicon",
333-
"SEO__FORM_FAVICON_DESC": " (Petit icône dans la barre du navigateur)",
333+
"SEO__FORM_FAVICON_DESC": "(Petit icône dans la barre du navigateur)",
334334
"SEO__FORM_IMG_URL": "Url de l'image",
335-
"SEO__FORM_IMG_URL_DESC": " (Pour Discord, Facebook, Twitter...) Laisser vide pour utiliser le favicon à la place",
335+
"SEO__FORM_IMG_URL_DESC": "(Pour Discord, Facebook, Twitter...) Laisser vide pour utiliser le favicon à la place",
336+
"SEO__FORM_THEME_COLOR": "Couleur thématique",
337+
"SEO__FORM_THEME_COLOR_DESC": "(Pour l'embed discord par exemple)",
338+
"SEO__FORM_TWITTER_SITE": "Tag Twitter",
339+
"SEO__FORM_TWITTER_SITE_DESC": "(De votre serveur par exemple)",
336340
"SEO__ADD_PAGE": "Ajouter une Page",
337341
"SEO__EDIT_PAGE": "Modifier une Page",
338342
"SEO__EDIT_SUCCESS": "Informations SEO éditées avec succès",

0 commit comments

Comments
 (0)