pars 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/Rackfile +0 -0
  3. data/bin/pars +58 -0
  4. data/lib/pars.rb +50 -0
  5. metadata +48 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07cd43bc978d9006fc983e2a0d7cd4d20bad2b18
4
+ data.tar.gz: aa4b0fe6ad8fe6582cb5be38e24daef11299f0bb
5
+ SHA512:
6
+ metadata.gz: 0cf7811f39a1b7a0eb1e44c70a52dd9da575fb3b27d5b650c1f24b3b0cf218d39361d19419a8621d2dd9ad15a2d2760ba6897e99296d95c416e6e9b565fde1c4
7
+ data.tar.gz: 86719416b30c504e50ab2501a3ed3735faafc3aae5ad3dbe5d949a3fbd7ff00e6604d4f46068a6c9ac215e8da2728c072b2abee6a179e6974642e2a475aaa8ca
File without changes
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require "fileutils"
5
+ require "redcarpet"
6
+ require "pars"
7
+
8
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
9
+ autolink: true, tables: true,
10
+ prettify: true,
11
+ fenced_code_blocks: true)
12
+
13
+ if Pars.isParsDir? then
14
+
15
+ if Pars.anyPost? then
16
+
17
+ header = File.open("view/header.html").read
18
+ footer = File.open("view/footer.html").read
19
+
20
+ File.delete('index.html') if File.exist?('index.html')
21
+
22
+ index = File.open("index.html","a")
23
+
24
+ Dir.foreach( Dir.pwd + "/posts" ) do |item|
25
+
26
+ puts item
27
+
28
+ # Remove . and .. file in from list
29
+ next if item == '.' or item == '..'
30
+
31
+
32
+ data = File.open(Dir.pwd + "/posts/" + item)
33
+
34
+ repc = { ".md" => ".html"}
35
+
36
+
37
+ FileUtils.touch( item.sub!(".md", ".html") )
38
+
39
+ File.open( Dir.pwd + "/" + item , 'w' ) do |file|
40
+ file.write( header + markdown.render(data.read) + footer)
41
+ end
42
+
43
+ index.write('<li><a href='+item +'>'+ item.sub!(".html", "") + '</a></li>')
44
+
45
+ data.close
46
+
47
+ puts "\n"
48
+ end
49
+
50
+ index.close
51
+ else
52
+
53
+ puts "posts not exists"
54
+ end
55
+
56
+ else
57
+ puts "Here is not a pars project."
58
+ end
@@ -0,0 +1,50 @@
1
+ require 'yaml'
2
+ require "fileutils"
3
+ require "kramdown"
4
+
5
+ class Pars
6
+
7
+ def self.isParsDir?
8
+ if File.exist?(".pars.yml") then
9
+ true
10
+ else
11
+ false
12
+ end
13
+ end
14
+
15
+ def self.anyPost?
16
+ if File.exist?(Dir.pwd + "/posts") then
17
+ true
18
+ else
19
+ false
20
+ end
21
+ end
22
+
23
+ def self.directory_hash(path, name=nil)
24
+
25
+ data = {:data => (name || path)}
26
+ data[:children] = children = []
27
+
28
+ Dir.foreach(path) do |entry|
29
+
30
+ next if (entry == '..' || entry == '.')
31
+
32
+ full_path = File.join(path, entry)
33
+
34
+ if File.directory?(full_path)
35
+ children << directory_hash(full_path, entry)
36
+ else
37
+ children << entry
38
+ end
39
+ end
40
+
41
+ return data
42
+ end
43
+
44
+ def self.generate
45
+ Dir.glob(Dir.pwd + "/posts/" + "*.md") do |doc|
46
+ puts doc
47
+ end
48
+ end
49
+
50
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pars
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dariush Abbasi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A static, static site generator!
14
+ email: poshtehani@gmail.com
15
+ executables:
16
+ - pars
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Rackfile
21
+ - bin/pars
22
+ - lib/pars.rb
23
+ homepage: http://github.com/dariubs/pars
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.4.6
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Pars
47
+ test_files: []
48
+ has_rdoc: