Module: Nsume::Prepare

Defined in:
lib/nsume/prepare.rb

Class Method Summary collapse

Class Method Details

.bootstrap_jsObject



28
29
30
31
# File 'lib/nsume/prepare.rb', line 28

def bootstrap_js
  endpoint = [Nsume.config.bootstrap_endpoint, 'dist', 'js', Nsume.config.bootstrap_js_file].join('/')
  asset Nsume.config.assets_js, Nsume.config.bootstrap_js_file, endpoint
end

.bootswatch_cssObject



33
34
35
36
# File 'lib/nsume/prepare.rb', line 33

def bootswatch_css
  endpoint = [Nsume.config.bootswatch_endpoint, Nsume.config.assets_css, Nsume.config.bootswatch_css_file].join('/')
  asset Nsume.config.assets_css, Nsume.config.bootswatch_css_file, endpoint
end

.bootswatch_jsObject



38
39
40
41
# File 'lib/nsume/prepare.rb', line 38

def bootswatch_js
  endpoint = [Nsume.config.bootswatch_endpoint, Nsume.config.assets_js, Nsume.config.bootswatch_js_file].join('/')
  asset Nsume.config.assets_js, Nsume.config.bootswatch_js_file, endpoint
end

.bootswatch_theme(theme = '') ⇒ Object



43
44
45
46
47
48
# File 'lib/nsume/prepare.rb', line 43

def bootswatch_theme(theme='')
  theme ||= Nsume.config.bootswatch_theme
  path = File.join(Nsume.config.assets_css, 'themes', theme)
  endpoint = [Nsume.config.bootswatch_endpoint, theme, Nsume.config.bootstrap_css_file].join('/')
  asset path, Nsume.config.bootstrap_css_file, endpoint
end

.generator(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nsume/prepare.rb', line 6

def generator(options={})
  Nsume::Logger.info 'Generating nSume...'

  path = File.expand_path('_config.yml', Nsume.config.dest_path)
  unless File.exists?(path)
    FileUtils.cp_r Nsume.config.generators_path + '/.', Nsume.config.dest_path

    basename = File.basename(Nsume.config.dest_path)
    baseurl = '/' + basename if options['site'] == 'project'
    year = Time.now.year

    file = ERB.new(Nsume.config.config_template).result(binding)
    File.write(path, file)

    self.navbar options['site']
  end
end

.jqueryObject



24
25
26
# File 'lib/nsume/prepare.rb', line 24

def jquery
  asset Nsume.config.assets_js, Nsume.config.jquery_file, Nsume.config.jquery_endpoint
end


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/nsume/prepare.rb', line 50

def navbar(site='')
  yaml = []

  YAML.load(Nsume.config.navbar_template).each do |nav|
    case site
    when 'user', 'blog'
      case nav['label'].downcase
      when 'blog', 'documentation'
        yaml << nav
      end
    when 'project', 'changelog'
      case nav['label'].downcase
      when 'changelog', 'documentation'
        yaml << nav
      end
    when 'api'
      case nav['label'].downcase
      when 'api', 'changelog', 'documentation'
        yaml << nav
      end
    end
  end

  path = File.join(Nsume.config.dest_path, '_data', 'navbar.yml')
  File.write(path, YAML.dump(yaml))
end