Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
244
Issues
244
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
ae4fcdaf
Commit
ae4fcdaf
authored
just now
by
Marcelo Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): SEO
parent
acb9a1ac
epic/minds-pro
1 merge request
!308
WIP: (feat): Minds Pro
Pipeline
#81134320
running with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
16 deletions
+29
-16
SEO.php
Core/Blogs/SEO.php
+16
-3
SEO.php
Core/Pro/SEO.php
+13
-13
No files found.
Core/Blogs/SEO.php
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
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
,
'
message
'
);
$title
=
$this
->
getEntityProperty
(
$entity
,
'title'
)
?:
$this
->
getEntityProperty
(
$entity
,
'
description
'
);
$siteName
=
$this
->
config
->
site_name
;
$description
=
$t
his
->
getEntityProperty
(
$entity
,
'blurb'
)
?:
"@
{
$owner
[
'username'
]
}
on
{
$siteName
}
"
;
$description
=
$t
itle
??
$this
->
getEntityProperty
(
$entity
,
'blurb'
)
??
"@
{
$owner
[
'username'
]
}
on
{
$siteName
}
"
;
$meta
=
[
'title'
=>
$title
,
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment