Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9565c41

Browse files
author
mostafa
committedApr 28, 2019
lara head
1 parent ca07e8d commit 9565c41

File tree

6 files changed

+58
-47
lines changed

6 files changed

+58
-47
lines changed
 

‎README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
# install
3+
# installation
44

55
```bash
66
composer require code4mk/lara-head
@@ -138,8 +138,9 @@ Khead::setTwitCards([
138138
{!! Khead::getTwitCards() !!}
139139
```
140140

141-
142141
# Head tags
143142

144143
* [gist link](https://gist.github.com/lancejpollard/1978404)
145144
* [gethead](https://gethead.info/)
145+
146+
<a href="https://twitter.com/0devco" target="_blank" ><p align="center" ><img src="https://raw.githubusercontent.com/0devco/docs/master/.devco-images/logo-transparent.png"></p></a>

‎config/.gitkeep

Whitespace-only changes.

‎src/Facades/Khead.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
namespace Code4mk\LaraHead\Facades;
44

5+
/**
6+
* @author @code4mk <hiremostafa@gmail.com>
7+
* @author @0devco <with@0dev.co>
8+
* @copyright 0dev.co (https://0dev.co)
9+
*/
10+
511
use Illuminate\Support\Facades\Facade;
612

713
/**

‎src/Og.php renamed to ‎src/Head.php

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
namespace Code4mk\LaraHead;
44

5+
/**
6+
* @author @code4mk <hiremostafa@gmail.com>
7+
* @author @0devco <with@0dev.co>
8+
* @copyright 0dev.co (https://0dev.co)
9+
*/
10+
511
use Illuminate\Support\HtmlString;
612
use Illuminate\Support\Arr;
713

8-
class Og
14+
class Head
915
{
10-
public $metas = [];
11-
public $ogs = [];
12-
public $cards = [];
13-
public $title;
16+
private $metas = [];
17+
private $links = [];
18+
private $scripts = [];
19+
private $ogs = [];
20+
private $cards = [];
21+
private $title;
1422

1523
public function setTitle($data)
1624
{
@@ -22,8 +30,6 @@ public function getTitle()
2230
return $this->title;
2331
}
2432

25-
26-
2733
public function setMeta($name,$data = [])
2834
{
2935
$this->metas[$name] = $this->toHtmlString('<meta' . $this->attributes($data) . '>');
@@ -34,14 +40,24 @@ public function getMeta($key)
3440
return Arr::get($this->metas, $key, '');
3541
}
3642

43+
public function setScript($name,$data = [])
44+
{
45+
$this->scripts[$name] = $this->toHtmlString('<script' . $this->attributes($data) . '>' . "" . "</script>");
46+
}
47+
48+
public function getScript($key)
49+
{
50+
return Arr::get($this->scripts, $key, '');
51+
}
52+
3753
public function setLink($name,$data = [])
3854
{
39-
$this->metas[$name] = $this->toHtmlString('<link' . $this->attributes($data) . '>');
55+
$this->links[$name] = $this->toHtmlString('<link' . $this->attributes($data) . '>');
4056
}
4157

4258
public function getLink($key)
4359
{
44-
return Arr::get($this->metas, $key, '');
60+
return Arr::get($this->links, $key, '');
4561
}
4662

4763
public function setOg($data = [])
@@ -53,9 +69,7 @@ public function setOg($data = [])
5369

5470
public function getOg()
5571
{
56-
//$m = implode("\n",$this->ogs)."</pre>";
5772
$m = "\t\t";
58-
5973
return implode("\n{$m}",$this->ogs);
6074
}
6175

@@ -68,14 +82,9 @@ public function setTwitCards($data = [])
6882

6983
public function getTwitCards()
7084
{
71-
//$m = implode("\n",$this->ogs)."</pre>";
7285
$m = "\t\t";
73-
7486
return implode("\n{$m}",$this->cards);
7587
}
76-
77-
78-
7988
/**
8089
* Build an HTML attribute string from an array.
8190
*
@@ -103,33 +112,22 @@ public function attributes($attributes)
103112
*
104113
* @return string
105114
*/
106-
protected function attributeElement($key, $value)
107-
{
108-
// For numeric keys we will assume that the value is a boolean attribute
109-
// where the presence of the attribute represents a true value and the
110-
// absence represents a false value.
111-
// This will convert HTML attributes such as "required" to a correct
112-
// form instead of using incorrect numerics.
113-
114-
115-
// Treat boolean attributes as HTML properties
116-
117-
118-
if (! is_null($value)) {
119-
return $key . '="' . e($value, false) . '"';
120-
}
121-
}
122-
123-
/**
124-
* Transform the string to an Html serializable object
125-
*
126-
* @param $html
127-
*
128-
* @return \Illuminate\Support\HtmlString
129-
*/
130-
protected function toHtmlString($html)
131-
{
132-
return new HtmlString($html);
115+
protected function attributeElement($key, $value)
116+
{
117+
if (! is_null($value)) {
118+
return $key . '="' . e($value, false) . '"';
133119
}
120+
}
134121

122+
/**
123+
* Transform the string to an Html serializable object
124+
*
125+
* @param $html
126+
*
127+
* @return \Illuminate\Support\HtmlString
128+
*/
129+
protected function toHtmlString($html)
130+
{
131+
return new HtmlString($html);
132+
}
135133
}

‎src/LaraHeadServiceProvider.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
namespace Code4mk\LaraHead;
44

5+
/**
6+
* @author @code4mk <hiremostafa@gmail.com>
7+
* @author @0devco <with@0dev.co>
8+
* @copyright 0dev.co (https://0dev.co)
9+
*/
10+
511
use Illuminate\Support\ServiceProvider;
612
use Illuminate\Foundation\AliasLoader;
7-
use Code4mk\LaraHead\Og;
13+
use Code4mk\LaraHead\Head as HeadMain;
814

915
/**
1016
* @author @code4mk <hiremostafa@gmail.com>
@@ -37,7 +43,7 @@ public function boot()
3743
public function register()
3844
{
3945
$this->app->bind('khead', function () {
40-
return new Og;
46+
return new HeadMain;
4147
});
4248
}
4349
}

‎test/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)
Please sign in to comment.