Skip to content

Commit

Permalink
Revert "Trying to fix build"
Browse files Browse the repository at this point in the history
This reverts commit ee851b2.
  • Loading branch information
DominicWatson committed Mar 12, 2024
1 parent f02baa2 commit 04471d8
Show file tree
Hide file tree
Showing 13 changed files with 387 additions and 5 deletions.
3 changes: 1 addition & 2 deletions api/rendering/SyntaxHighlighter.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ component {
var jars = [ "../lib/pyg-in-blankets-1.0-SNAPSHOT-jar-with-dependencies.jar" ];
var highlighter = CreateObject( 'java', 'com.dominicwatson.pyginblankets.PygmentsWrapper', jars );

if ( arguments.language == "luceescript" || arguments.language == "cfc" ) {
if ( arguments.language == "luceescript" ) {
arguments.language = "cfs";
}
if ( arguments.language == "lucee" ) {
Expand All @@ -30,7 +30,6 @@ component {
} catch( any e ) {
throw( type="docs.syntax.highlight.error", message="Error highlighting code for language [#arguments.language#]: [#arguments.code#]")
}
return arguments.code;
}

// PRIVATE HELPERS
Expand Down
144 changes: 144 additions & 0 deletions builders/dash/Builder.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
component extends="builders.html.Builder" {

// PUBLIC API
public void function build( docTree, buildDirectory ) {
var tree = docTree.getTree();
var docsetRoot = arguments.buildDirectory & "/presidecms.docset/";
var contentRoot = docsetRoot & "Contents/";
var resourcesRoot = contentRoot & "Resources/";
var docsRoot = resourcesRoot & "Documents/";
var ignorePages = [ "download" ]


if ( !DirectoryExists( arguments.buildDirectory ) ) { DirectoryCreate( arguments.buildDirectory ); }
if ( !DirectoryExists( docsetRoot ) ) { DirectoryCreate( docsetRoot ); }
if ( !DirectoryExists( contentRoot ) ) { DirectoryCreate( contentRoot ); }
if ( !DirectoryExists( resourcesRoot ) ) { DirectoryCreate( resourcesRoot ); }
if ( !DirectoryExists( docsRoot ) ) { DirectoryCreate( docsRoot ); }

try {
_setupSqlLite( resourcesRoot );

for( var page in tree ) {
if ( !ignorePages.find( page.getId() ) ) {
_writePage( page, docsRoot, docTree );
_storePageInSqliteDb( page );
}
}
} catch ( any e ) {
rethrow;
} finally {
_closeDbConnection();
}

_copyResources( docsetRoot );
_renameSqlLiteDb( resourcesRoot );
_setupFeedXml( arguments.buildDirectory & "/" );
}

public string function renderLink( any page, required string title ) {

if ( IsNull( arguments.page ) ) {
return '<a class="missing-link">#HtmlEditFormat( arguments.title )#</a>';
}

var link = page.getId() & ".html";

return '<a href="#link#">#HtmlEditFormat( arguments.title )#</a>';
}

// PRIVATE HELPERS
private string function _getHtmlFilePath( required any page, required string buildDirectory ) {
if ( arguments.page.getPath() == "/home" ) {
return arguments.buildDirectory & "/index.html";
}

return arguments.buildDirectory & arguments.page.getId() & ".html";
}

private void function _copyResources( required string rootDir ) {
FileCopy( "/builders/dash/resources/Info.plist", arguments.rootDir & "Contents/Info.plist" );
FileCopy( "/builders/dash/resources/icon.png", arguments.rootDir & "icon.png" );
DirectoryCopy( "/builders/html/assets/css/", arguments.rootDir & "Contents/Resources/Documents/assets/css", true, "*", true );
DirectoryCopy( "/builders/html/assets/images/", arguments.rootDir & "Contents/Resources/Documents/assets/images", true, "*", true );
DirectoryCopy( "/docs/_images/", arguments.rootDir & "Contents/Resources/Documents/images", true, "*", true );
}

private void function _setupSqlLite( required string rootDir ) {
variables.sqlite = _getSqlLiteCfc();
variables.dbFile = sqlite.createDb( dbName="docSet", destDir=arguments.rootDir & "/" );
variables.dbConnection = sqlite.getConnection( dbFile );

sqlite.executeSql( dbFile, "CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT)", false, dbConnection );
sqlite.executeSql( dbFile, "CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path)", false, dbConnection );
}

private any function _getSqlLiteCfc() {
return new api.sqlitecfc.SqliteCFC(
tempdir = ExpandPath( "/api/sqlitecfc/tmp/" )
, libdir = ExpandPath( "/api/sqlitecfc/lib/" )
, model_path = "/api/sqlitecfc"
, dot_model_path = "api.sqlitecfc"
);
}

private void function _storePageInSqliteDb( required any page ) {
var dashPageType = "Guide";

switch( page.getPageType() ){
case "function":
dashPageType = "Function";
break;
case "method":
dashPageType = "Method";
break;
case "service":
dashPageType = "Service";
break;
case "presideobject":
dashPageType = "Object";
break;
case "form":
dashPageType = "File";
break;
case "category":
dashPageType = "Category";
break;
}

var data = {
name = Replace( page.getTitle(), "'", "''", "all" )
, type = dashPageType
, path = page.getId() & ".html"
};

data.path = page.getId() & ".html";

sqlite.executeSql( dbFile, "INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('#data.name#', '#data.type#', '#data.path#')", false, dbConnection );

for( var child in page.getChildren() ){
_storePageInSqliteDb( child );
}
}

private void function _closeDbConnection() {
if ( StructKeyExists( variables, "dbConnection" ) ) {
dbConnection.close();
}
}

private void function _renameSqlLiteDb( required string rootDir ) {
FileMove( rootDir & "docSet.db", rootDir & "docSet.dsidx" );
}

private void function _setupFeedXml( required string rootDir ) {
var feedXml = FileRead( "/builders/dash/resources/feed.xml" );
var buildProps = new api.build.BuildProperties();

feedXml = Replace( feedXml, "{url}" , buildProps.getDashDownloadUrl(), "all" );
feedXml = Replace( feedXml, "{version}", buildProps.getDashBuildNumber(), "all" );

FileWrite( arguments.rootDir & "presidecms.xml", feedXml );

}
}
14 changes: 14 additions & 0 deletions builders/dash/layouts/breadcrumbs.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<cfparam name="args.crumbs" type="array" />
<cfparam name="args.page" type="any" />

<cfif args.page.getId() neq "/home">
<cfoutput>
<ul class="breadcrumb margin-no-top margin-right margin-no-bottom margin-left">
<li><a href="index.html">Home</a></li>
<cfloop array="#args.crumbs#" item="pageSlug" index="i">
<li>[[#pageSlug#]]</li>
</cfloop>
<li class="active">#HtmlEditFormat( args.page.getTitle() )#</li>
</ul>
</cfoutput>
</cfif>
80 changes: 80 additions & 0 deletions builders/dash/layouts/main.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<cfparam name="args.body" type="string" />
<cfparam name="args.page" type="any" />
<cfparam name="args.crumbs" type="string" />
<cfparam name="args.navTree" type="string" />
<cfparam name="args.seeAlso" type="string" />

<cfoutput><!DOCTYPE html>
<html>
<head>
<title>Preside Documentation :: #HtmlEditFormat( args.page.getTitle() )#</title>
<base href="">
<meta content="initial-scale=1.0, width=device-width" name="viewport">
<link href="assets/css/base.min.css" rel="stylesheet">
<link href="assets/css/highlight.css" rel="stylesheet">
<link rel="icon" type="image/png" href="assets/images/preside-favicon.png">
</head>

<body class="#LCase( args.page.getPageType() )#" style="margin-bottom:150px;">
<header class="header">
<a class="header-logo hidden-lg" href="index.html"><img src="assets/images/preside-platform.svg"></a>
<ul class="nav nav-list pull-right">
<cfset prevPage = args.page.getPreviousPage() />
<cfset nextPage = args.page.getNextPage() />
<cfif not IsNull( prevPage )>
<li>
<a href="#( prevPage.getPath() == '/home' ? '/' : '#prevPage.getId()#.html' )#">
<span class="access-hide">Previous page: #HtmlEditFormat( prevPage.getTitle() )#</span>
<span class="icon icon-arrow-back icon-lg"></span>
</a>
</li>
</cfif>
<cfif not IsNull( nextPage )>
<li>
<a href="#( nextPage.getPath() == '/home' ? '/' : '#nextPage.getId()#.html' )#">
<span class="access-hide">Previous page: #HtmlEditFormat( nextPage.getTitle() )#</span>
<span class="icon icon-arrow-forward icon-lg"></span>
</a>
</li>
</cfif>
</ul>
<span class="header-fix-show header-logo pull-none text-overflow">#HtmlEditFormat( args.page.getTitle() )#</span>
</header>

<div class="content">
<div class="content-heading">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-push-1">
<h1 class="heading">#HtmlEditFormat( args.page.getTitle() )#</h1>
</div>
</div>
</div>
</div>

<div class="content-inner">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-push-1 body">
<div class="tile-wrap">
<div class="tile">
#args.crumbs#
</div>
</div>
#args.body#
#args.seeAlso#
</div>
</div>
</div>
</div>
</div>

<footer class="footer">
<div class="container">
<p>The Preside Documentation is developed and maintained by Pixl8 Interactive and is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>.
</p>
</div>
</footer>
</body>
</html></cfoutput>
10 changes: 10 additions & 0 deletions builders/dash/layouts/seeAlso.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<cfif ( args.links ?: [] ).len()>
<cfoutput>
<h2>See also</h2>
<ul class="list-unstyled">
<cfloop array="#args.links#" index="i" item="link">
<li>#link#</li>
</cfloop>
</ul>
</cfoutput>
</cfif>
42 changes: 42 additions & 0 deletions builders/dash/layouts/sideNavTree.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<cfparam name="args.pageLineage" type="array" />
<cfparam name="args.crumbs" type="array" />
<cfparam name="args.docTree" type="any" />

<cfoutput>
<ul class="nav">
<cfloop array="#args.docTree.getTree()#" item="firstLevelPage" index="i">
<cfif firstLevelPage.getId() neq "/home" && firstLevelPage.getVisible()>
<cfset firstLevelActive = args.pageLineage.find( firstLevelPage.getId() ) />
<cfset firstLevelCurrent = args.pageLineage[ args.pageLineage.len() ] == firstLevelPage.getId() />
<li class="<cfif firstLevelActive>active</cfif> <cfif firstLevelCurrent>current</cfif>">

[[#firstLevelPage.getId()#]]

<cfset subIsOpen = firstLevelActive />
<cfsavecontent variable="subnav">
<cfloop array="#firstLevelPage.getChildren()#" item="secondLevelPage" index="n">
<cfif secondLevelPage.getVisible()>
<cfset secondLevelActive = args.pageLineage.find( secondLevelPage.getId() ) />
<cfif secondLevelActive>
<cfset subIsOpen = true />
</cfif>
<li<cfif secondLevelActive> class="active"</cfif>>[[#secondLevelPage.getId()#]]</li>
</cfif>
</cfloop>
</cfsavecontent>


<cfif Trim( subnav ).len()>
<span class="menu-collapse-toggle <cfif !subIsOpen>collapsed</cfif>" data-target="###firstLevelPage.getId()#" data-toggle="collapse" aria-expanded="#subIsOpen#">
<i class="icon icon-close menu-collapse-toggle-close"></i>
<i class="icon icon-add menu-collapse-toggle-default"></i>
</span>
<ul class="menu-collapse <cfif subIsOpen>expand<cfelse>collapse</cfif>" id="#firstLevelPage.getId()#">
#subnav#
</ul>
</cfif>
</li>
</cfif>
</cfloop>
</ul>
</cfoutput>
14 changes: 14 additions & 0 deletions builders/dash/resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>presidecms</string>
<key>CFBundleName</key>
<string>PresideCMS</string>
<key>DocSetPlatformFamily</key>
<string>presidecms</string>
<key>isDashDocset</key>
<true/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions builders/dash/resources/feed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<entry>
<version>{version}</version>
<url>{url}</url>
</entry>
Binary file added builders/dash/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions builders/dash/templates/aToZIndex.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<cfparam name="args.page" type="page" />

<cfset pg = args.page />
<cfset currentLetter = "" />

<cfoutput>
<a class="pull-right" href="#getSourceLink( path=pg.getSourceFile() )#" title="Improve the docs"><i class="fa fa-pencil fa-fw"></i></a>
#markdownToHtml( pg.getBody() )#

<div class="row row-clear">
<cfloop array="#pg.getChildren()#" index="i" item="child">
<cfset slug = child.getSlug() />
<cfset firstLetter = slug[1] />
<cfif firstLetter != currentLetter>
<cfif currentLetter.len()>
</ul>
</div>
</cfif>
<div class="col-lg-3 col-md-4 col-sm-6 col-xx-12">
<h2 class="content-sub-heading">#UCase( firstLetter )#</h2>
<ul class="nav tile-wrap">
</cfif>

<li><a class="tile" href="#child.getId()#.html"><span class="text-overflow">#HtmlEditFormat( child.getTitle() )#</span></a></li>

<cfset currentLetter = firstLetter />
</cfloop>
</ul></div>
</div>
</cfoutput>
Loading

0 comments on commit 04471d8

Please sign in to comment.