Verified Commit a0848929 authored by Aral Balkan's avatar Aral Balkan
Browse files

Remove generation of app content from

parent af58886d
......@@ -8,7 +8,7 @@
# ▲❤ We practice Ethical Design (
# © Aral Balkan. © All Rights Reserved.
# © 2016-2018 Aral Balkan. © All Rights Reserved.
# Released with love by under GNU AGPLv3 or later.
# Free as in freedom. Please see the LICENSE file.
......@@ -50,13 +50,9 @@ class App
themesDirectory: null
commonThemeDirectory: null
siteThemeDirectory: null
appThemeDirectory: null
themeForSiteDataDirectory: null
themeForAppDataDirectory: null
# TODO: Refactor: rename appTheme to appTheme
appTheme: null
siteTheme: null
isRunningInDevelopment: false
......@@ -87,21 +83,17 @@ class App
# Initialise global properties of the app.
# @identifier = 'builder'
@homeDirectory = path.join osPath.home(), ''
@privateDirectory = path.join @homeDirectory, '.private'
@logsDirectory = path.join @privateDirectory, 'logs'
# Set up cache-related properties if we’re running in development.
# (We don’t use the cache when in production.)
# Set up cache-related properties.
if @isRunningInDevelopment
@cacheDirectory = path.join @privateDirectory, 'cache'
@rulePartialsDirectory = path.join @cacheDirectory, 'rule-partials'
@dataForSiteCacheDirectory = path.join @cacheDirectory, 'data', 'site'
@indicesDirectory = path.join @cacheDirectory, 'indices'
fs.ensureDirSync @indicesDirectory
@cacheDirectory = path.join @privateDirectory, 'cache'
@rulePartialsDirectory = path.join @cacheDirectory, 'rule-partials'
@dataForSiteCacheDirectory = path.join @cacheDirectory, 'data', 'site'
@indicesDirectory = path.join @cacheDirectory, 'indices'
fs.ensureDirSync @indicesDirectory
# Set up logging.
logFile = path.join @logsDirectory, 'App.log'
......@@ -133,12 +125,10 @@ class App
@themesDirectory = path.join @homeDirectory, 'themes'
@commonThemeDirectory = path.join @themesDirectory, 'common'
@siteThemeDirectory = path.join @themesDirectory, 'site'
@appThemeDirectory = path.join @themesDirectory, 'app'
# These are the themes that are generated from the source themes, above.
@themeForSiteDataDirectory = '/tmp/theme-for-site'
@themeForAppDataDirectory = '/tmp/theme-for-app'
# Store and return reference to singleton instance.
instance = @
return instance
......@@ -232,7 +222,7 @@ class App
# And if there are no changes, we don’t need to generate themes.
for fileName, lastModifiedDate of themeCachePreviousModifiedTimes
if lastModifiedDate != themeCacheCurrentModifiedTimes[fileName]
# There are changes, generate themes.
# There are changes, generate themes. "\t✓ Change to theme found in #{fileName}, generating theme."
@themeHasNotChanged = false
return true
......@@ -248,13 +238,9 @@ class App
if @weNeedToGenerateThemes() "\t✓ Generating theme…"
fs.removeAsync @themeForAppDataDirectory
.then => fs.removeAsync @themeForSiteDataDirectory
.then => fs.copyAsync @commonThemeDirectory, @themeForAppDataDirectory
fs.removeAsync @themeForSiteDataDirectory
.then => fs.copyAsync @commonThemeDirectory, @themeForSiteDataDirectory
.then => fs.copyAsync @appThemeDirectory, @themeForAppDataDirectory
.then => fs.copyAsync @siteThemeDirectory, @themeForSiteDataDirectory
.then => @generateStylesForThemeAtDirectory @themeForAppDataDirectory
.then => @generateStylesForThemeAtDirectory @themeForSiteDataDirectory
.then => endTime = new Date; "\t✓ Theme generated. (#{endTime - startTime} ms)"
.catch (e) =>
......@@ -280,15 +266,14 @@ class App
@log.debug 'Loading themes.'
appTemplatesDirectory = path.join @appThemeDirectory, 'templates'
siteTemplatesDirectory = path.join @siteThemeDirectory, 'templates'
commonTemplatesDirectory = path.join @commonThemeDirectory, 'templates'
# Copies common templates as properties into the passed theme object.
addCommonTemplatesTo = (theme) -> (Object.keys commonTheme).forEach (key) -> theme[key] = commonTheme[key]
# These are templates common to both themes.
commonTheme =
# These are templates common to both themes.
@siteTheme =
# TODO: Refactor. The templates are loaded from two different directories as we were previously
# using mostly the same themes to generate content for both the app and site. Now we only generate
# content for the site.
news: fs.readFileSync (path.join commonTemplatesDirectory, 'news/index.html'), 'utf-8'
spotlight: fs.readFileSync (path.join commonTemplatesDirectory, 'spotlight/index.html'), 'utf-8'
spotlightIssue1: fs.readFileSync (path.join commonTemplatesDirectory, 'spotlight/1/index.html'), 'utf-8'
......@@ -296,23 +281,12 @@ class App
trackers: fs.readFileSync (path.join commonTemplatesDirectory, 'trackers/index.html'), 'utf-8'
improvements: fs.readFileSync (path.join commonTemplatesDirectory, 'partials/improvements.html'), 'utf-8'
table: fs.readFileSync (path.join commonTemplatesDirectory, 'partials/table.html'), 'utf-8'
@appTheme =
header: fs.readFileSync (path.join appTemplatesDirectory, 'header.html'), 'utf-8'
page: fs.readFileSync (path.join appTemplatesDirectory, 'page.html'), 'utf-8'
home: fs.readFileSync (path.join appTemplatesDirectory, 'home.html'), 'utf-8'
addCommonTemplatesTo @appTheme
@siteTheme =
header: fs.readFileSync (path.join siteTemplatesDirectory, 'header.html'), 'utf-8'
page: fs.readFileSync (path.join siteTemplatesDirectory, 'page.html'), 'utf-8'
home: fs.readFileSync (path.join siteTemplatesDirectory, 'home.html'), 'utf-8'
reviews: fs.readFileSync (path.join siteTemplatesDirectory, 'reviews/index.html'), 'utf-8'
support: fs.readFileSync (path.join siteTemplatesDirectory, 'support/index.html'), 'utf-8'
addCommonTemplatesTo @siteTheme
# Returns a reference to the App singleton.
module.exports = new App
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment