diff --git a/api/rendering/SyntaxHighlighter.cfc b/api/rendering/SyntaxHighlighter.cfc index e67d3fd..a165201 100644 --- a/api/rendering/SyntaxHighlighter.cfc +++ b/api/rendering/SyntaxHighlighter.cfc @@ -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" ) { @@ -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 diff --git a/builders/dash/Builder.cfc b/builders/dash/Builder.cfc new file mode 100644 index 0000000..6841357 --- /dev/null +++ b/builders/dash/Builder.cfc @@ -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 '#HtmlEditFormat( arguments.title )#'; + } + + var link = page.getId() & ".html"; + + return '#HtmlEditFormat( arguments.title )#'; + } + +// 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 ); + + } +} \ No newline at end of file diff --git a/builders/dash/layouts/breadcrumbs.cfm b/builders/dash/layouts/breadcrumbs.cfm new file mode 100644 index 0000000..631a556 --- /dev/null +++ b/builders/dash/layouts/breadcrumbs.cfm @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/builders/dash/layouts/main.cfm b/builders/dash/layouts/main.cfm new file mode 100644 index 0000000..69dedd1 --- /dev/null +++ b/builders/dash/layouts/main.cfm @@ -0,0 +1,80 @@ + + + + + + + + + + Preside Documentation :: #HtmlEditFormat( args.page.getTitle() )# + + + + + + + + +
+ + + +
+ +
+
+
+
+
+

#HtmlEditFormat( args.page.getTitle() )#

+
+
+
+
+ +
+
+
+
+
+
+ #args.crumbs# +
+
+ #args.body# + #args.seeAlso# +
+
+
+
+
+ + + +
\ No newline at end of file diff --git a/builders/dash/layouts/seeAlso.cfm b/builders/dash/layouts/seeAlso.cfm new file mode 100644 index 0000000..ba92ed1 --- /dev/null +++ b/builders/dash/layouts/seeAlso.cfm @@ -0,0 +1,10 @@ + + +

See also

+
    + +
  • #link#
  • +
    +
+
+
\ No newline at end of file diff --git a/builders/dash/layouts/sideNavTree.cfm b/builders/dash/layouts/sideNavTree.cfm new file mode 100644 index 0000000..ead0df3 --- /dev/null +++ b/builders/dash/layouts/sideNavTree.cfm @@ -0,0 +1,42 @@ + + + + + + + \ No newline at end of file diff --git a/builders/dash/resources/Info.plist b/builders/dash/resources/Info.plist new file mode 100644 index 0000000..f773f2b --- /dev/null +++ b/builders/dash/resources/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + presidecms + CFBundleName + PresideCMS + DocSetPlatformFamily + presidecms + isDashDocset + + + diff --git a/builders/dash/resources/feed.xml b/builders/dash/resources/feed.xml new file mode 100644 index 0000000..d59bd4e --- /dev/null +++ b/builders/dash/resources/feed.xml @@ -0,0 +1,4 @@ + + {version} + {url} + \ No newline at end of file diff --git a/builders/dash/resources/icon.png b/builders/dash/resources/icon.png new file mode 100644 index 0000000..b9ff2ac Binary files /dev/null and b/builders/dash/resources/icon.png differ diff --git a/builders/dash/templates/aToZIndex.cfm b/builders/dash/templates/aToZIndex.cfm new file mode 100644 index 0000000..6ad6596 --- /dev/null +++ b/builders/dash/templates/aToZIndex.cfm @@ -0,0 +1,30 @@ + + + + + + + + #markdownToHtml( pg.getBody() )# + +
+ + + + + + +
+ +
+

#UCase( firstLetter )#

+
+ +
\ No newline at end of file diff --git a/builders/dash/templates/category.cfm b/builders/dash/templates/category.cfm new file mode 100644 index 0000000..0452b7a --- /dev/null +++ b/builders/dash/templates/category.cfm @@ -0,0 +1,39 @@ + + + + + category = args.page; + pages = args.docTree.getPagesByCategory( category.getSlug() ); + pages = args.docTree.sortPagesByType( pages ); + + currentPageType = ""; + pageTypeTitles = { + "function" = "Functions" + , tag = "Tags" + }; + + + + + + + #markdownToHtml( category.getBody() )# + + +

There are no pages tagged with this category.

+ + + + + + + +

#( pageTypeTitles[ page.getPageType() ] ?: "Other articles" )#

+
    + + +
  • [[#page.getId()#]]
  • + +
+
+
\ No newline at end of file diff --git a/builders/dash/templates/page.cfm b/builders/dash/templates/page.cfm new file mode 100644 index 0000000..328afa2 --- /dev/null +++ b/builders/dash/templates/page.cfm @@ -0,0 +1,8 @@ + + + + + + + #markdownToHtml( pg.getBody() )# + \ No newline at end of file diff --git a/builders/html/layouts/main.cfm b/builders/html/layouts/main.cfm index 068ae54..bb9d03b 100644 --- a/builders/html/layouts/main.cfm +++ b/builders/html/layouts/main.cfm @@ -9,9 +9,7 @@ Preside Documentation :: #HtmlEditFormat( args.page.getTitle() )# - - - +