Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99425744
DivinerStaticPublisher.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jan 24, 11:13
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jan 26, 11:13 (1 d, 16 h)
Engine
blob
Format
Raw Data
Handle
23797866
Attached To
rPH Phabricator
DivinerStaticPublisher.php
View Options
<?php
final
class
DivinerStaticPublisher
extends
DivinerPublisher
{
protected
function
loadAllPublishedHashes
()
{
return
array
();
}
protected
function
deleteDocumentsByHash
(
array
$hashes
)
{
return
;
}
protected
function
createDocumentsByHash
(
array
$hashes
)
{
foreach
(
$hashes
as
$hash
)
{
$atom
=
$this
->
getAtomFromGraphHash
(
$hash
);
if
(!
$this
->
shouldGenerateDocumentForAtom
(
$atom
))
{
continue
;
}
$content
=
$this
->
getRenderer
()->
renderAtom
(
$atom
);
$this
->
writeDocument
(
$atom
,
$content
);
}
}
private
function
writeDocument
(
DivinerAtom
$atom
,
$content
)
{
$root
=
$this
->
getConfig
(
'root'
);
$path
=
$root
.
DIRECTORY_SEPARATOR
.
$this
->
getAtomRelativePath
(
$atom
);
if
(!
Filesystem
::
pathExists
(
$path
))
{
Filesystem
::
createDirectory
(
$path
,
$umask
=
0755
,
$recursive
=
true
);
}
Filesystem
::
writeFile
(
$path
.
'index.html'
,
$content
);
}
private
function
getAtomRelativePath
(
DivinerAtom
$atom
)
{
$ref
=
$atom
->
getRef
();
$book
=
$ref
->
getBook
();
$type
=
$ref
->
getType
();
$context
=
$ref
->
getContext
();
$name
=
$ref
->
getName
();
$path
=
array
(
'docs'
,
$book
,
$type
,
);
if
(
$context
!==
null
)
{
$path
[]
=
$context
;
}
$path
[]
=
$name
;
$index
=
$this
->
getAtomSimilarIndex
(
$atom
);
if
(
$index
!==
null
)
{
$path
[]
=
'@'
.
$index
;
}
$path
[]
=
null
;
return
implode
(
DIRECTORY_SEPARATOR
,
$path
);
}
}
Event Timeline
Log In to Comment