Module: Gitki

Defined in:
lib/gitki.rb

Defined Under Namespace

Classes: Attachment, Page

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_defaultsObject



20
21
22
23
24
25
# File 'lib/gitki.rb', line 20

def create_defaults
  @@store[Page.dir + '/home'] = read_file('home_template.haml')
  @@store[Page.dir + '/navigation'] = read_file('navigation_template.haml')
  @@store[Attachment.dir + '/gitki.png'] = read_file('gitki.png')
  @@store.commit 'Created defaults'
end

.read_file(name) ⇒ Object



27
28
29
# File 'lib/gitki.rb', line 27

def read_file(name)
  open(File.dirname(__FILE__) + '/' + name).read
end

.setup(git_store_path) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/gitki.rb', line 11

def setup(git_store_path)
  @@store = GitStore.new(File.expand_path(git_store_path), 'master', true) # use bare repository
  Page.setup('wiki')
  Attachment.setup('files')
  if @@store.objects.empty?
    create_defaults
  end
end

Instance Method Details

#html(text) ⇒ Object



48
49
50
# File 'lib/gitki.rb', line 48

def html(text)
  text
end

#markdown(text) ⇒ Object



44
45
46
# File 'lib/gitki.rb', line 44

def markdown(text)
  RDiscount.new(text).to_html
end

#markup_typesObject



32
33
34
# File 'lib/gitki.rb', line 32

def markup_types
  ['html', 'textile', 'markdown']
end

#storeObject



36
37
38
# File 'lib/gitki.rb', line 36

def store
  @@store
end

#textile(text) ⇒ Object



40
41
42
# File 'lib/gitki.rb', line 40

def textile(text)
  RedCloth.new(text).to_html
end