wikitxt 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -2
- data/README.md +25 -8
- data/lib/wikitxt/cli.rb +10 -8
- data/lib/wikitxt/node.rb +2 -2
- data/lib/wikitxt/server.rb +30 -0
- data/lib/wikitxt/version.rb +1 -1
- data/lib/wikitxt/views/index.erb +3 -0
- data/lib/{html/layout.html.erb → wikitxt/views/layout.erb} +15 -0
- data/samples/Wikitxt.txt +33 -0
- data/wikitxt.gemspec +2 -1
- metadata +21 -7
- data/Guardfile +0 -4
- data/lib/html/index.html.erb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8fad6d59c01705bbe4b224a2e2b0c8aeec33f5dc565764fe9a30b0eee2f3429
|
4
|
+
data.tar.gz: 68e2f0f840d5d6b89d6ae308fb00205b8abaa3e95c6eb01e3905f4d02b6185d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63363c50d0698f4445f56f25b8f022a900a23f42ad1d237ec01d2f6057c68cca4f7e77a5d043a319f722886d1a5e5105bf6c48a62084d409824e9d37a9d51f7f
|
7
|
+
data.tar.gz: ad0569bc3741639ed7ce2eb4173b485c34e2ba790648b3d4b6d7f9afece0693041f4d248be12da97343145626125c4448a967959b472278bc156fcffeef23320
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wikitxt (0.1.
|
4
|
+
wikitxt (0.1.6)
|
5
|
+
rackup (~> 2.1)
|
6
|
+
sinatra (~> 4.0)
|
5
7
|
thor (~> 1.3)
|
6
|
-
webrick (~> 1.8)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
12
|
+
base64 (0.2.0)
|
11
13
|
coderay (1.1.3)
|
12
14
|
diff-lcs (1.5.1)
|
13
15
|
ffi (1.16.3)
|
@@ -30,6 +32,8 @@ GEM
|
|
30
32
|
rb-inotify (~> 0.9, >= 0.9.10)
|
31
33
|
lumberjack (1.2.10)
|
32
34
|
method_source (1.0.0)
|
35
|
+
mustermann (3.0.0)
|
36
|
+
ruby2_keywords (~> 0.0.1)
|
33
37
|
nenv (0.3.0)
|
34
38
|
notiffany (0.1.3)
|
35
39
|
nenv (~> 0.1)
|
@@ -37,6 +41,15 @@ GEM
|
|
37
41
|
pry (0.14.2)
|
38
42
|
coderay (~> 1.1)
|
39
43
|
method_source (~> 1.0)
|
44
|
+
rack (3.0.10)
|
45
|
+
rack-protection (4.0.0)
|
46
|
+
base64 (>= 0.1.0)
|
47
|
+
rack (>= 3.0.0, < 4)
|
48
|
+
rack-session (2.0.0)
|
49
|
+
rack (>= 3.0.0)
|
50
|
+
rackup (2.1.0)
|
51
|
+
rack (>= 3)
|
52
|
+
webrick (~> 1.8)
|
40
53
|
rake (13.2.1)
|
41
54
|
rb-fsevent (0.11.2)
|
42
55
|
rb-inotify (0.10.1)
|
@@ -54,10 +67,18 @@ GEM
|
|
54
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
68
|
rspec-support (~> 3.13.0)
|
56
69
|
rspec-support (3.13.1)
|
70
|
+
ruby2_keywords (0.0.5)
|
57
71
|
shellany (0.0.1)
|
72
|
+
sinatra (4.0.0)
|
73
|
+
mustermann (~> 3.0)
|
74
|
+
rack (>= 3.0.0, < 4)
|
75
|
+
rack-protection (= 4.0.0)
|
76
|
+
rack-session (>= 2.0.0, < 3)
|
77
|
+
tilt (~> 2.0)
|
58
78
|
spoon (0.0.6)
|
59
79
|
ffi
|
60
80
|
thor (1.3.1)
|
81
|
+
tilt (2.3.0)
|
61
82
|
webrick (1.8.1)
|
62
83
|
|
63
84
|
PLATFORMS
|
data/README.md
CHANGED
@@ -8,6 +8,23 @@ Most lightweight markup language and personal knowledge manager or wiki platform
|
|
8
8
|
|
9
9
|
![screenshot](https://github.com/kawakamimoeki/wikitxt/blob/main/docs/screenshot.png)
|
10
10
|
|
11
|
+
Wikitxt is a lightweight markup language and a tool for composing Wiki . The syntax of #Wikitxt can be converted to HTML and viewed in a browser. When converted to HTML, files can be interlinked.
|
12
|
+
|
13
|
+
Wikitxt is based on the format of lists and paragraphs. Most information can be expressed in list format, and the choice between lists and paragraphs is always changing as you write.
|
14
|
+
|
15
|
+
Text decoration is limited to mutual links using hashtags. By utilizing the decoration of mutual links, you can intentionally increase the number of pages in the wiki.
|
16
|
+
|
17
|
+
In summary, it's like this:
|
18
|
+
|
19
|
+
- Lists
|
20
|
+
- Based on the idea that most information can be expressed in lists
|
21
|
+
- Paragraphs
|
22
|
+
- Paragraphs always have the potential to be listed. They can easily be converted to lists.
|
23
|
+
- Paragraphs can also serve as headings.
|
24
|
+
- Mutual Links
|
25
|
+
- Text decoration is limited to links.
|
26
|
+
- Words you want to emphasize should be expressed as wiki pages.
|
27
|
+
|
11
28
|
## Installation
|
12
29
|
|
13
30
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -73,12 +90,6 @@ Wikitxt.to_html(text)
|
|
73
90
|
|
74
91
|
### Server
|
75
92
|
|
76
|
-
`wiki/index.txt`:
|
77
|
-
|
78
|
-
```
|
79
|
-
Link to #sample .
|
80
|
-
```
|
81
|
-
|
82
93
|
`wiki/sample.txt`:
|
83
94
|
|
84
95
|
```
|
@@ -101,10 +112,16 @@ Cras at tortor urna. Maecenas nec iaculis nulla.
|
|
101
112
|
```
|
102
113
|
|
103
114
|
```
|
104
|
-
$ wikitxt s
|
115
|
+
$ wikitxt s wiki
|
105
116
|
```
|
106
117
|
|
107
|
-
Access to http://localhost:
|
118
|
+
Access to http://localhost:4567 .
|
119
|
+
|
120
|
+
### Build
|
121
|
+
|
122
|
+
```
|
123
|
+
$ wikitxt build wiki
|
124
|
+
```
|
108
125
|
|
109
126
|
## Development
|
110
127
|
|
data/lib/wikitxt/cli.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "thor"
|
2
|
-
require 'webrick'
|
3
2
|
require 'erb'
|
4
3
|
require 'fileutils'
|
5
4
|
|
@@ -7,9 +6,15 @@ module Wikitxt
|
|
7
6
|
class CLI < Thor
|
8
7
|
package_name "wikitxt"
|
9
8
|
map "s" => :server
|
9
|
+
map "b" => :build
|
10
10
|
|
11
|
-
desc "server
|
11
|
+
desc "server PATH", "start wiki site"
|
12
12
|
def server(path)
|
13
|
+
system("DIR=\"#{path}\" ruby #{File.join(__dir__, "server.rb")}")
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "build PATH", "build wiki site"
|
17
|
+
def build(path)
|
13
18
|
files = Dir.glob(File.join(path, "*.txt"))
|
14
19
|
pages = []
|
15
20
|
files.each do |file|
|
@@ -17,18 +22,15 @@ module Wikitxt
|
|
17
22
|
body = Wikitxt.to_html(text)
|
18
23
|
title = File.basename(file, ".txt")
|
19
24
|
pages << title
|
20
|
-
html = ERB.new(File.read(File.join(__dir__, "
|
25
|
+
html = ERB.new(File.read(File.join(__dir__, "views", "layout.erb"))).result_with_hash({ body: body, title: title })
|
21
26
|
Dir.mkdir("dist") unless Dir.exist?("dist")
|
22
27
|
File.write(File.join("dist", "#{title}.html"), html)
|
23
28
|
end
|
24
|
-
index = ERB.new(File.read(File.join(__dir__, "
|
25
|
-
html = ERB.new(File.read(File.join(__dir__, "
|
29
|
+
index = ERB.new(File.read(File.join(__dir__, "views", "index.erb"))).result_with_hash({ pages: pages })
|
30
|
+
html = ERB.new(File.read(File.join(__dir__, "views", "layout.erb"))).result_with_hash({ body: index, title: "Index" })
|
26
31
|
File.write(File.join("dist", "index.html"), html)
|
27
32
|
images = Dir.glob(File.join(path, "*.{png,jpg,jpeg}"))
|
28
33
|
FileUtils.cp(images, "dist")
|
29
|
-
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => "dist"
|
30
|
-
trap 'INT' do server.shutdown end
|
31
|
-
server.start
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
data/lib/wikitxt/node.rb
CHANGED
@@ -39,13 +39,13 @@ module Wikitxt
|
|
39
39
|
|
40
40
|
class TextNode < BaseNode
|
41
41
|
def to_html
|
42
|
-
"<span>#{attrs[:text]}</span>"
|
42
|
+
"<span>#{CGI.escapeHTML(attrs[:text])}</span>"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
class LinkNode < BaseNode
|
47
47
|
def to_html
|
48
|
-
" <a href=\"#{attrs[:url]}\">#{attrs[:title]}</a> "
|
48
|
+
" <a href=\"#{attrs[:url]}\">#{CGI.escapeHTML(attrs[:title])}</a> "
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'wikitxt'
|
3
|
+
|
4
|
+
get "/" do
|
5
|
+
pages = Dir.glob(File.join(ENV["DIR"], "*.txt")).map { File.basename(_1, ".txt") }
|
6
|
+
title = "Index"
|
7
|
+
body = ERB.new(File.read(File.join(__dir__, "views", "index.erb"))).result_with_hash({ pages: pages })
|
8
|
+
ERB.new(File.read(File.join(__dir__, "views", "layout.erb"))).result_with_hash({ body: body, title: title })
|
9
|
+
end
|
10
|
+
|
11
|
+
get "/:page" do
|
12
|
+
page = params[:page]
|
13
|
+
|
14
|
+
if page.match?(/\.(png|jpeg|jpg)/)
|
15
|
+
pass unless File.exist?(File.join(ENV["DIR"], page))
|
16
|
+
send_file File.join(ENV["DIR"], page)
|
17
|
+
end
|
18
|
+
|
19
|
+
page = File.basename(page, ".html")
|
20
|
+
file = File.join(ENV["DIR"], "#{page}.txt")
|
21
|
+
pass unless File.exist?(file)
|
22
|
+
text = File.read(file)
|
23
|
+
title = File.basename(file, ".txt")
|
24
|
+
body = Wikitxt.to_html(text)
|
25
|
+
ERB.new(File.read(File.join(__dir__, "views", "layout.erb"))).result_with_hash({ body: body, title: title })
|
26
|
+
end
|
27
|
+
|
28
|
+
not_found do
|
29
|
+
ERB.new(File.read(File.join(__dir__, "views", "layout.erb"))).result_with_hash({ body: "Not found", title: "Not found" })
|
30
|
+
end
|
data/lib/wikitxt/version.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
<head>
|
2
2
|
<meta charset="UTF-8" />
|
3
|
+
<title><%= title.capitalize %></title>
|
3
4
|
</head>
|
4
5
|
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background: #ddd;
|
8
9
|
padding: 1rem;
|
10
|
+
word-break: break-all;
|
9
11
|
}
|
10
12
|
|
11
13
|
.content {
|
@@ -36,6 +38,19 @@
|
|
36
38
|
border-radius: 100%;
|
37
39
|
}
|
38
40
|
|
41
|
+
pre, code {
|
42
|
+
background: #eee;
|
43
|
+
}
|
44
|
+
|
45
|
+
pre .dot, code .dot {
|
46
|
+
background: none;
|
47
|
+
}
|
48
|
+
|
49
|
+
blockquote {
|
50
|
+
background: #eee;
|
51
|
+
font-style: italic;
|
52
|
+
}
|
53
|
+
|
39
54
|
img {
|
40
55
|
max-width: 100%;
|
41
56
|
}
|
data/samples/Wikitxt.txt
CHANGED
@@ -18,3 +18,36 @@ In summary, it's like this:
|
|
18
18
|
Absolute url is parsed as external link: #<https://example.com Example Domain>
|
19
19
|
|
20
20
|
#woman.jpg
|
21
|
+
|
22
|
+
やってること
|
23
|
+
パラグラフ
|
24
|
+
リスト
|
25
|
+
リンク
|
26
|
+
画像
|
27
|
+
やってないこと
|
28
|
+
#装飾文字
|
29
|
+
これはいらない気もする
|
30
|
+
#コードブロック
|
31
|
+
#引用
|
32
|
+
#自動リンク
|
33
|
+
コードスパンがないのでURLを生で書きたい時に困る
|
34
|
+
コードブロックというかpreはは必要なのか
|
35
|
+
というか #コードブロック の記法を作るくらいならpreタグを使うのとさほど変わらないのでは
|
36
|
+
|
37
|
+
<code>
|
38
|
+
class Hoge
|
39
|
+
def initialize(fuga)
|
40
|
+
@fuga = fuga
|
41
|
+
end
|
42
|
+
end
|
43
|
+
</code>
|
44
|
+
|
45
|
+
↑preタグの中にもリストができてしまったので修正必要そう。
|
46
|
+
|
47
|
+
インラインは良さそう: <pre>これはpreタグの中身です</pre>
|
48
|
+
|
49
|
+
と思ったがpreタグは改行されるのか
|
50
|
+
|
51
|
+
<blockquote>
|
52
|
+
ホゲホゲ
|
53
|
+
</blockquote>
|
data/wikitxt.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikitxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moeki Kawakami
|
@@ -25,19 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: sinatra
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rackup
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.1'
|
41
55
|
description: Most lightweight markup language and personal knowledge manager or wiki
|
42
56
|
platform.
|
43
57
|
email:
|
@@ -52,20 +66,20 @@ files:
|
|
52
66
|
- CODE_OF_CONDUCT.md
|
53
67
|
- Gemfile
|
54
68
|
- Gemfile.lock
|
55
|
-
- Guardfile
|
56
69
|
- LICENSE.txt
|
57
70
|
- README.md
|
58
71
|
- Rakefile
|
59
72
|
- docs/screenshot.png
|
60
73
|
- exe/wikitxt
|
61
|
-
- lib/html/index.html.erb
|
62
|
-
- lib/html/layout.html.erb
|
63
74
|
- lib/wikitxt.rb
|
64
75
|
- lib/wikitxt/cli.rb
|
65
76
|
- lib/wikitxt/node.rb
|
66
77
|
- lib/wikitxt/parser.rb
|
67
78
|
- lib/wikitxt/renderer.rb
|
79
|
+
- lib/wikitxt/server.rb
|
68
80
|
- lib/wikitxt/version.rb
|
81
|
+
- lib/wikitxt/views/index.erb
|
82
|
+
- lib/wikitxt/views/layout.erb
|
69
83
|
- samples/Wikitxt.txt
|
70
84
|
- samples/woman.jpg
|
71
85
|
- wikitxt.gemspec
|
data/Guardfile
DELETED
data/lib/html/index.html.erb
DELETED