Add directory and ImportPaths paths to themes

This commit is contained in:
Ben Ogle
2013-08-13 16:51:21 -07:00
parent c3850e4d44
commit 8730638ade
4 changed files with 16 additions and 3 deletions

View File

@@ -24,6 +24,12 @@ describe "ThemeManager", ->
config.set('core.themes', [])
expect($('style.userTheme').length).toBe 0
# atom-dark-ui has an directory path, the syntax ones dont.
config.set('core.themes', ['atom-light-syntax', 'atom-dark-ui', 'atom-dark-syntax'])
importPaths = themeManager.getImportPaths()
expect(importPaths.length).toBe 1
expect(importPaths[0]).toContain 'atom-dark-ui'
describe "when a theme fails to load", ->
it "logs a warning", ->
themeManager = new ThemeManager()

View File

@@ -18,6 +18,7 @@ describe "Theme", ->
themePath = project.resolve('themes/theme-stylesheet.css')
theme = new Theme(themePath)
expect($(".editor").css("padding-top")).toBe "1234px"
expect(theme.directoryPath).not.toBeDefined()
it "parses, loads and applies less", ->
expect($(".editor").css("padding-bottom")).not.toBe "1234px"
@@ -33,6 +34,7 @@ describe "Theme", ->
themePath = project.resolve('themes/theme-with-package-file')
theme = new Theme(themePath)
expect(theme.directoryPath).toBe themePath
expect($(".editor").css("padding-top")).toBe("101px")
expect($(".editor").css("padding-right")).toBe("102px")
expect($(".editor").css("padding-bottom")).toBe("103px")
@@ -45,6 +47,7 @@ describe "Theme", ->
themePath = project.resolve('themes/theme-without-package-file')
theme = new Theme(themePath)
expect(theme.directoryPath).toBe themePath
expect($(".editor").css("padding-top")).toBe "10px"
expect($(".editor").css("padding-right")).toBe "20px"
expect($(".editor").css("padding-bottom")).toBe "30px"

View File

@@ -40,6 +40,9 @@ class ThemeManager
else
null
getImportPaths: ->
(theme.directoryPath for theme in @loadedThemes when theme.directoryPath)
loadUserStylesheet: ->
if userStylesheetPath = @getUserStylesheetPath()
@userStylesheetPath = userStylesheetPath

View File

@@ -24,11 +24,12 @@ class Theme
if path.extname(@stylesheetPath) in ['.css', '.less']
@loadStylesheet(@stylesheetPath)
else
@directoryPath = @stylesheetPath
metadataPath = fsUtils.resolveExtension(path.join(@stylesheetPath, 'package'), ['cson', 'json'])
if fsUtils.isFileSync(metadataPath)
stylesheetNames = fsUtils.readObjectSync(metadataPath)?.stylesheets
if stylesheetNames
for name in stylesheetNames
@metadata = fsUtils.readObjectSync(metadataPath)
if @metadata?.stylesheets
for name in @metadata.stylesheets
filename = fsUtils.resolveExtension(path.join(@stylesheetPath, name), ['.css', '.less', ''])
@loadStylesheet(filename)
else