Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Documentation
Docs Publisher
Commits
cdaaacdb
Commit
cdaaacdb
authored
Oct 13, 2022
by
homotechsual
Browse files
Merge branch 'email_url' into 'master'
Changed url in e-mail to point to the repo See merge request
!108
parents
9fd1dc03
8c37a098
Changes
8
Hide whitespace changes
Inline
Side-by-side
.env
View file @
cdaaacdb
...
...
@@ -3,4 +3,5 @@ APP_SECRET=ThisTokenIsNotSoSecretChangeIt
PLAUSIBLE_DOMAIN=docs.civicrm.org
APP_SECRET=bdee8dad7d0e844f214ecc1477b01f77
MAILER_DSN=null://null
APP_ENV=dev
\ No newline at end of file
APP_ENV=dev
DOCS_URL=https://docs.civicrm.org
.env.test
View file @
cdaaacdb
...
...
@@ -6,4 +6,5 @@ APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER
=
999999
PANTHER_APP_ENV
=
panther
PANTHER_ERROR_SCREENSHOT_DIR
=
.
/
var
/
error
-
screenshots
PLAUSIBLE_DOMAIN
=
localhost
\ No newline at end of file
PLAUSIBLE_DOMAIN
=
localhost
DOCS_URL
=
http
://
localhost
config/services.yaml
View file @
cdaaacdb
...
...
@@ -19,6 +19,7 @@ services:
$kernelRoot
:
'
%kernel.project_dir%'
$cacheDir
:
'
%kernel.cache_dir%'
$redirecter
:
'
@redirecter'
$docsUrl
:
'
%env(DOCS_URL)%'
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
...
...
src/Controller/PublishController.php
View file @
cdaaacdb
...
...
@@ -24,7 +24,7 @@ class PublishController extends AbstractController {
* @var bool TRUE if the book was published without any errors
*/
private
$publishSuccess
;
public
function
__construct
(
Library
$library
,
Publisher
$publisher
,
...
...
@@ -36,7 +36,7 @@ class PublishController extends AbstractController {
$this
->
webhookprocessor
=
$webhookprocessor
;
$this
->
mailer
=
$mailer
;
}
/**
* @param string $identifier
*
...
...
@@ -110,10 +110,10 @@ class PublishController extends AbstractController {
/** @var \App\Model\Book */
$book
=
$this
->
library
->
getBookBySlug
(
$parts
[
'bookSlug'
]);
$language
=
$book
->
getLanguageByCode
(
$parts
[
'languageCode'
]);
$version
=
$language
->
getVersionByDescriptor
(
$parts
[
'versionDescriptor'
]);
$webPath
=
sprintf
(
'%s/%s/%s'
,
$book
->
slug
,
$language
->
code
,
$version
->
branch
)
;
$webPath
=
$version
->
url
;
$subject
=
"Publishing Successful"
;
$rawRecipients
=
array_unique
(
array_merge
(
$extraRecipients
,
$language
->
watchers
));
...
...
src/Model/Book.php
View file @
cdaaacdb
...
...
@@ -49,8 +49,9 @@ class Book {
* @param string $confFile
* The path to the yaml configuration file which defines the attributes
* of the book.
* @param string $docsUrl
*/
public
function
__construct
(
$confFile
)
{
public
function
__construct
(
$confFile
,
string
$docsUrl
)
{
$parser
=
new
Parser
();
$yaml
=
$parser
->
parse
(
file_get_contents
(
$confFile
));
$this
->
slug
=
StringTools
::
urlSafe
(
basename
(
$confFile
,
'.yml'
));
...
...
@@ -59,7 +60,7 @@ class Book {
$this
->
weight
=
isset
(
$yaml
[
'weight'
])
?
$yaml
[
'weight'
]
:
0
;
$this
->
description
=
isset
(
$yaml
[
'description'
])
?
$yaml
[
'description'
]
:
""
;
foreach
(
$yaml
[
'langs'
]
as
$code
=>
$languageData
)
{
$this
->
languages
[]
=
new
Language
(
$code
,
$languageData
);
$this
->
languages
[]
=
new
Language
(
$code
,
$languageData
,
$docsUrl
.
'/'
.
$this
->
slug
);
}
$category
=
isset
(
$yaml
[
'category'
])
?
$yaml
[
'category'
]
:
"extension"
;
$this
->
category
=
ucwords
(
$category
);
...
...
src/Model/Language.php
View file @
cdaaacdb
...
...
@@ -40,7 +40,7 @@ class Language implements \Countable {
return
count
(
$this
->
versions
);
}
}
/**
* Initialize a language with values in it.
*
...
...
@@ -49,11 +49,13 @@ class Language implements \Countable {
*
* @param array $yaml
* Language data from a book's yaml file
* @param string $docsUrl
* The public URL of the docs website. E.g. https://docs.civicrm.org
*/
public
function
__construct
(
$code
,
$yaml
)
{
public
function
__construct
(
$code
,
$yaml
,
string
$docsUrl
)
{
$this
->
code
=
$code
;
$this
->
repo
=
$yaml
[
'repo'
];
$this
->
setupVersions
(
$yaml
);
$this
->
setupVersions
(
$yaml
,
$docsUrl
.
'/'
.
$this
->
code
);
if
(
isset
(
$yaml
[
'watchers'
]))
{
foreach
(
$yaml
[
'watchers'
]
as
$watcher
)
{
$this
->
watchers
[]
=
$watcher
;
...
...
@@ -66,8 +68,10 @@ class Language implements \Countable {
*
* @param array $yaml
* Data passed into the language constructor.
* @param string $docsUrl
* The public URL of the docs website. E.g. https://docs.civicrm.org
*/
private
function
setupVersions
(
$yaml
):
void
{
private
function
setupVersions
(
$yaml
,
string
$docsUrl
):
void
{
// Add versions defined in yaml
$versions
=
$yaml
[
'versions'
]
??
[];
foreach
(
$versions
as
$slug
=>
$version
)
{
...
...
@@ -75,12 +79,12 @@ class Language implements \Countable {
$path
=
$version
[
'path'
]
??
$slug
;
$branch
=
$version
[
'branch'
]
??
'master'
;
$redirects
=
$version
[
'redirects'
]
??
[];
$this
->
versions
[]
=
new
Version
(
$slug
,
$name
,
$path
,
$branch
,
$redirects
);
$this
->
versions
[]
=
new
Version
(
$slug
,
$name
,
$path
,
$branch
,
$redirects
,
$docsUrl
);
}
// If no versions were defined, then add one version (with default values)
if
(
empty
(
$this
->
versions
))
{
$this
->
versions
[]
=
new
Version
(
'latest'
,
'Latest'
,
'latest'
,
'master'
,
[
'stable'
,
'current'
]);
$this
->
versions
[]
=
new
Version
(
'latest'
,
'Latest'
,
'latest'
,
'master'
,
[
'stable'
,
'current'
]
,
$docsUrl
);
}
}
...
...
src/Model/Library.php
View file @
cdaaacdb
...
...
@@ -17,11 +17,12 @@ class Library {
*
* @param string $booksDir
*/
public
function
__construct
(
string
$booksDir
)
{
public
function
__construct
(
string
$booksDir
,
string
$docsUrl
)
{
$this
->
docsUrl
=
$docsUrl
;
$finder
=
new
Finder
();
$files
=
$finder
->
in
(
$booksDir
)
->
name
(
"*.yml"
);
foreach
(
$files
as
$file
)
{
$book
=
new
Book
(
$file
);
$book
=
new
Book
(
$file
,
$docsUrl
);
$this
->
books
[]
=
$book
;
}
$this
->
sortBooks
();
...
...
src/Model/Version.php
View file @
cdaaacdb
...
...
@@ -50,6 +50,12 @@ class Version {
*/
public
$redirects
;
/**
* @var string
* The public url to this book.
*/
public
$url
=
''
;
/**
* Defines a new "version" of a book, with aliases.
* A version has one and only
...
...
@@ -73,19 +79,25 @@ class Version {
* @see Version::branch
* @param array $redirects
* @see Version::redirects
* @param string $docsUrl
* The public URL of the docs website. E.g. https://docs.civicrm.org
*/
public
function
__construct
(
$slug
=
'latest'
,
$name
=
'Latest'
,
$path
=
null
,
$branch
=
'master'
,
$redirects
=
[]
$redirects
=
[],
string
$docsUrl
=
''
)
{
$this
->
slug
=
$slug
;
$this
->
name
=
$name
;
$this
->
path
=
$path
??
$slug
;
$this
->
branch
=
$branch
;
$this
->
setupRedirects
(
$redirects
);
if
(
$docsUrl
)
{
$this
->
url
=
$docsUrl
.
'/'
.
$this
->
slug
;
}
}
/**
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment