Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
Minds Backend - Engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
Minds
Minds Backend - Engine
Commits
ae4fcdaf
Commit
ae4fcdaf
authored
5 years ago
by
Marcelo Rivera
Browse files
Options
Downloads
Patches
Plain Diff
(feat): SEO
parent
acb9a1ac
No related branches found
Branches containing commit
No related tags found
Loading
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Blogs/SEO.php
+16
-3
16 additions, 3 deletions
Core/Blogs/SEO.php
Core/Pro/SEO.php
+13
-13
13 additions, 13 deletions
Core/Pro/SEO.php
with
29 additions
and
16 deletions
Core/Blogs/SEO.php
+
16
−
3
View file @
ae4fcdaf
...
...
@@ -6,6 +6,7 @@ use Minds\Core;
use
Minds\Entities
;
use
Minds\Helpers
;
use
Minds\Helpers\Counters
;
use
Zend\Diactoros\ServerRequestFactory
;
class
SEO
{
...
...
@@ -76,18 +77,30 @@ class SEO
$params
=
$event
->
getParameters
();
$slugs
=
$params
[
'slugs'
];
if
((
count
(
$slugs
)
<
3
)
||
(
$slugs
[
1
]
!=
'blog'
))
{
/** @var Core\Pro\Domain $proDomain */
$proDomain
=
Core\Di\Di
::
_
()
->
get
(
'Pro\Domain'
);
$request
=
ServerRequestFactory
::
fromGlobals
();
$serverParams
=
$request
->
getServerParams
()
??
[];
$host
=
parse_url
(
$serverParams
[
'HTTP_ORIGIN'
]
??
''
,
PHP_URL_HOST
)
?:
$serverParams
[
'HTTP_HOST'
];
$proSettings
=
$proDomain
->
lookup
(
$host
);
if
(
$proSettings
&&
(
count
(
$slugs
)
<
2
||
$slugs
[
0
]
===
'blog'
))
{
$slugParts
=
explode
(
'-'
,
$slugs
[
1
]);
}
elseif
(
!
$proSettings
&&
count
(
$slugs
)
>=
3
&&
$slugs
[
1
]
===
'blog'
)
{
$slugParts
=
explode
(
'-'
,
$slugs
[
2
]);
}
else
{
return
;
}
$slugParts
=
explode
(
'-'
,
$slugs
[
2
]);
$guid
=
$slugParts
[
count
(
$slugParts
)
-
1
];
if
(
!
is_numeric
(
$guid
))
{
return
;
}
$event
->
setResponse
(
$this
->
viewHandler
([
$guid
]));
$event
->
setResponse
(
$this
->
viewHandler
([
$guid
]));
});
}
...
...
This diff is collapsed.
Click to expand it.
Core/Pro/SEO.php
+
13
−
13
View file @
ae4fcdaf
...
...
@@ -66,16 +66,9 @@ class SEO
'og:image'
=>
$this
->
user
->
getIconURL
(
'large'
),
]);
Manager
::
add
(
'/feed'
,
[
$this
,
'activityHandler'
]);
Manager
::
add
(
'/videos'
,
[
$this
,
'entityHandler'
]);
Manager
::
add
(
'/images'
,
[
$this
,
'entityHandler'
]);
Manager
::
add
(
'/articles'
,
[
$this
,
'entityHandler'
]);
Manager
::
add
(
'/groups'
,
[
$this
,
'entityHandler'
]);
// Manager::add('/login', [$this, 'entityHandler']);
// blog slugs
// media slugs
Manager
::
add
(
'/newsfeed'
,
[
$this
,
'activityHandler'
]);
Manager
::
add
(
'/media'
,
[
$this
,
'entityHandler'
]);
// blog route added in Blogs\SEO
}
function
activityHandler
(
$slugs
=
[])
...
...
@@ -124,7 +117,14 @@ class SEO
function
getEntityProperty
(
$entity
,
$prop
)
{
$getter
=
"get${$prop}"
;
return
Helpers\MagicAttributes
::
getterExists
(
$entity
,
$getter
)
?
$entity
->
{
$getter
}()
:
$entity
->
{
$prop
};
if
(
isset
(
$entity
->
{
$prop
}))
{
return
$entity
->
{
$prop
};
}
else
if
(
Helpers\MagicAttributes
::
getterExists
(
$entity
,
$getter
))
{
return
$entity
->
{
$getter
}();
}
return
null
;
}
function
entityHandler
(
$slugs
=
[])
...
...
@@ -144,11 +144,11 @@ class SEO
$owner
=
$this
->
getEntityProperty
(
$entity
,
'ownerObj'
);
$title
=
$this
->
getEntityProperty
(
$entity
,
'title'
)
?:
$this
->
getEntityProperty
(
$entity
,
'
m
es
sage
'
);
$title
=
$this
->
getEntityProperty
(
$entity
,
'title'
)
?:
$this
->
getEntityProperty
(
$entity
,
'
d
es
cription
'
);
$siteName
=
$this
->
config
->
site_name
;
$description
=
$this
->
getEntityProperty
(
$entity
,
'blurb'
)
?
:
"@
{
$owner
[
'username'
]
}
on
{
$siteName
}
"
;
$description
=
$title
??
$this
->
getEntityProperty
(
$entity
,
'blurb'
)
?
?
"@
{
$owner
[
'username'
]
}
on
{
$siteName
}
"
;
$meta
=
[
'title'
=>
$title
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment