Skip to content

Commit 3e79fc8

Browse files
committed
- Change landing page
1 parent b00d547 commit 3e79fc8

24 files changed

Lines changed: 682 additions & 263 deletions

Gemfile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
source 'https://rubygems.org'
22

3-
# gem 'jekyll'
4-
5-
# This gem is for local GitHub pages development, but it conflicts with
6-
# CmomonMarker (it requires a lower version than we need)
7-
# gem 'github-pages', group: :jekyll_plugins
8-
93
gem 'byebug'
4+
gem 'filewatcher-cli'
105
gem 'lp'
6+
gem 'pretty_trace'
117
gem 'rack-test'
12-
gem 'rdoc'
13-
gem 'rentacop'
148
gem 'rspec'
15-
gem 'rspec_approvals'
169
gem 'rspec-html-matchers'
10+
gem 'rspec_approvals'
1711
gem 'runfile'
1812
gem 'runfile-tasks'
1913
gem 'sasstool'
2014
gem 'simplecov'
21-
gem 'yard'
15+
gem 'slim'
2216

2317
gemspec

README.md

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![Madness Logo](assets/header.png)
2+
13
# Madness - Instant Markdown Server
24

35
[![Gem Version](https://badge.fury.io/rb/madness.svg)](https://badge.fury.io/rb/madness)
@@ -6,34 +8,15 @@
68

79
---
810

9-
## Screenshots (click to zoom)
10-
11-
<table><tr>
12-
<td><a target='_screenshot' href='assets/screen-main.png'><img src='assets/screen-main.png'/></a></td>
13-
<td><a target='_screenshot' href='assets/screen-nav.png'><img src='assets/screen-nav.png'/></a></td>
14-
<td><a target='_screenshot' href='assets/screen-code.png'><img src='assets/screen-code.png'/></a></td>
15-
<td><a target='_screenshot' href='assets/screen-search.png'><img src='assets/screen-search.png'/></a></td>
16-
</tr></table>
17-
18-
## Table of Contents
19-
20-
* [Install](#install)
21-
* [Design Intentions](#design-intentions)
22-
* [Feature Highlights](#feature-highlights)
23-
* [Usage](#usage)
24-
* [Directory Conventions](#directory-conventions)
25-
* [Configuration File](#configuration-file)
26-
* [Search](#search)
27-
* [Images and Static Files](#images-and-static-files)
28-
* [Automatic H1](#automatic-h1)
29-
* [Shortlinks](#shortlinks)
30-
* [Table of Contents Generation](#table-of-contents-generation)
31-
* [Hidden Directories](#hidden-directories)
32-
* [Controlling Sort Order](#controlling-sort-order)
33-
* [Displaying Additional File Types](#displaying-additional-file-types)
34-
* [Basic Authentication](#basic-authentication)
35-
* [Customizing Theme](#customizing-theme)
36-
* [Docker Image](#docker-image)
11+
Madness is a command line server for rendering markdown documents in your
12+
browser. It is designed to facilitate easy development of internal
13+
markdown-based documentation site.
14+
15+
<!-- MADNESS_TOC -->
16+
17+
## Screenshots
18+
19+
[![Screenshots](assets/screenshots.gif)](assets/screenshots.gif)
3720

3821
## Install
3922

@@ -56,11 +39,6 @@ $ brew gem install madness
5639
$ alias madness='docker run --rm -it -v $PWD:/docs -p 3000:3000 dannyben/madness'
5740
```
5841

59-
## Design Intentions
60-
61-
Madness was designed in order to provide easy browsing, viewing and
62-
searching for local, markdown based documentation directories.
63-
6442
## Feature Highlights
6543

6644
- Easy to use.
@@ -69,9 +47,13 @@ searching for local, markdown based documentation directories.
6947
- Configure with a configuration file or command arguments.
7048
- Fully customizable theme.
7149
- Automatic generation of navigation sidebar.
72-
- Automatic generation of Table of Contents (site-wide and inline).
73-
- Can optionally show additional file types in the navigation menu (e.g. PDF files).
50+
- Automatic generation of Table of Contents (site-wide and per page).
51+
- Can optionally show additional file types in the navigation menu (e.g. PDF
52+
files).
7453
- Optional support for `[[Short Link]]` syntax.
54+
- Optional basic authentication.
55+
- Support for extended markdown syntax, such as footnotes and syntax
56+
highlighting.
7557

7658
## Usage
7759

@@ -93,14 +75,14 @@ $ madness --help
9375

9476
Madness expects to be executed in a documentation directory.
9577

96-
A documentation directory contains only markdown files (`*.md`) and
97-
sub directories that contain more markdown files.
78+
A documentation directory contains only markdown files (`*.md`) and sub
79+
directories that contain more markdown files.
9880

99-
The server will consider the file `index.md` or `README.md` in any directory
100-
as the main file describing this directory, where `index.md` has priority.
81+
The server will consider the file `index.md` or `README.md` in any directory as
82+
the main file describing this directory, where `index.md` has priority.
10183

102-
The navigation sidebar will show all the sub directories and files in
103-
the same directory as the viewed file.
84+
The navigation sidebar will show all the sub directories and files in the same
85+
directory as the viewed file.
10486

10587
Example structure:
10688

@@ -119,9 +101,17 @@ Example structure:
119101

120102
## Configuration File
121103

122-
All the command line arguments can also be configured through a
123-
configuration file. Create a file named `.madness.yml` in your
124-
documentation directory, and modify any of the settings below.
104+
Madness uses sensible defaults, so therefore can be executed without configuring
105+
anything. Configuration is mostly done by having a file named `.madness.yml` in
106+
your documentation directory.
107+
108+
For convenience, you can generate a template config file by running:
109+
110+
```shell
111+
$ madness create config
112+
```
113+
114+
which will generate this file, with all the default options:
125115

126116
```yaml
127117
# .madness.yml
@@ -144,12 +134,14 @@ auto_h1: true
144134
# append navigation to directory READMEs
145135
auto_nav: true
146136

137+
# replace <!-- TOC --> in any file with its internal table of contents
138+
# set to true to enable it with the default '## Table of Contents' caption,
139+
# or set to any string that will be inserted before it as a caption.
140+
auto_toc: true
141+
147142
# enable syntax highlighter for code snippets
148143
highlighter: true
149144

150-
# enable line numbers for code snippets
151-
line_numbers: true
152-
153145
# enable the copy to clipboard icon for code snippets
154146
copy_code: true
155147

@@ -183,12 +175,6 @@ expose_extensions: ~
183175
exclude: ['^[a-z_\-0-9]+$']
184176
```
185177
186-
For convenience, you can generate a template config file by running:
187-
188-
```shell
189-
$ madness create config
190-
```
191-
192178
## Search
193179
194180
Madness comes with a full text search page.
@@ -235,13 +221,18 @@ file or a directory in the same directory as the file itself.
235221
To generate a Table of Contents file for the entire site (for the directories
236222
and files), run `madness --toc FILENAME`
237223

238-
### Inline
224+
### In-page
239225

240226
If you have long markdown documents, and you wish to add an inline Table of
241227
Contents for them, simply add an HTML comment `<!-- TOC -->` where you want
242228
the Table of Contents to be generated. The inserted list will only consider
243229
H2 and H3 headings.
244230

231+
Note that for this feature to work, your markdown document must use the #-based
232+
heading syntax.
233+
234+
The 'Table of Contents' heading can be customized in the configuration file.
235+
245236
## Hidden Directories
246237

247238
Directories that are made only of lowercase letters, underscoes, dash and/or

Runfile

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require_relative 'lib/madness'
22
require "sasstool"
3+
require "slim"
4+
require "pretty_trace/enable-trim"
35
require "runfile-tasks"
46

57
title "Madness Runfile"
@@ -8,18 +10,18 @@ version Madness::VERSION
810

911
RunfileTasks::RubyGems.all 'madness'
1012
RunfileTasks::Testing.rspec
11-
RunfileTasks::Docs.rdoc
1213

1314
help "Generate public CSS"
14-
action :css do
15-
target = "app/public/css"
16-
Sasstool::Renderer.new("app/styles/main.scss").save target
17-
puts "Saved #{target}"
18-
end
19-
20-
help "Run YARD server"
21-
action :yard do
22-
system "yard server -p3000 -B0.0.0.0 -r"
15+
usage 'css [--watch]'
16+
option '-w, --watch', 'Watch for changes and regenerate'
17+
action :css do |args|
18+
if args['--watch']
19+
exec "filewatcher --immediate 'app/styles/*.scss' 'bundle exec run css'"
20+
else
21+
target = "app/public/css"
22+
Sasstool::Renderer.new("app/styles/main.scss").save target
23+
puts "Saved #{target}"
24+
end
2325
end
2426

2527
usage "(server|s) [--sample]"
@@ -30,21 +32,16 @@ action :server, :s do |args|
3032
system "bundle exec bin/madness #{folder}"
3133
end
3234

33-
help "Run IRB console"
34-
action :console, :c do
35-
system "bundle exec bin/console"
36-
end
37-
38-
help "Generate TOC to toc.txt"
39-
action :toc do
40-
exec 'gh-md-toc README.md > toc.txt'
41-
end
35+
help 'Extract fontello zip'
36+
action :fontello do
37+
system 'mkdir -p tmp/fontello'
38+
zip = 'assets/fontello.zip'
39+
system "unzip -j -o #{zip} -d tmp/fontello"
40+
%w[eot svg ttf woff woff2].each do |ext|
41+
system "cp tmp/fontello/fontello.#{ext} app/public/font/"
42+
end
4243

43-
help "Generate usage.md"
44-
action :usage do
45-
content = "# Madness Usage\n\n```shell\n$ madness --help\n\n#{`bundle exec madness --help`}\n```\n"
46-
File.write 'usage.md', content
47-
puts "Created usage.md"
44+
system 'cp tmp/fontello/fontello.css app/styles/_fontello.scss'
4845
end
4946

5047
help "Generate changelog and append old changelog"
@@ -59,10 +56,35 @@ action :cloc do
5956
system "cloc . --exclude-dir coverage,spec,examples"
6057
end
6158

62-
help "Run a local Jekyll deployment for GitHub Pages tests"
63-
usage "jekyll"
64-
action :jekyll do |args|
65-
exec "jekyll serve -H 0.0.0.0 -P 3000"
59+
help "Generate the screenshots animated gif"
60+
action :screenshots do
61+
puts "Saving assets/screenshots.gif"
62+
exec "convert -delay 300 -loop 0 assets/screenshots/*.png assets/screenshots.gif"
63+
end
64+
65+
help "Generate the site to /docs"
66+
action :site do
67+
# Use the README as a base, and do some TOC acrobatics to prevent the HTML
68+
# generator from converting some TOC comments.
69+
readme = File.read('README.md')
70+
.gsub('<!-- TOC -->', '{{TOC_COMMENT}}')
71+
.gsub('<!-- MADNESS_TOC -->', '<!-- TOC -->')
72+
.sub(/\[!\[Gem Version\].*/, '')
73+
.sub(/\[!\[Build Status\].*/, '')
74+
.sub(/\[!\[Maintainability\].*/, '')
75+
76+
# Create the Madness page using Madness
77+
content = Madness::MarkdownDocument.new(readme)
78+
.to_html
79+
.gsub '{{TOC_COMMENT}}', '&lt;!-- TOC --&gt;'
80+
81+
# Place the rendered HTML inside a slim template
82+
Slim::Engine.set_options pretty: true
83+
html = Slim::Template.new("assets/site/index.slim").render(nil, content: content)
84+
85+
# Export for GitHub pages
86+
File.write 'docs/index.html', html
87+
puts 'Saved docs/index.html'
6688
end
6789

6890
require_relative 'debug.rb' if File.exist? 'debug.rb'

_config.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

_layouts/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

_layouts/default.html

Lines changed: 0 additions & 65 deletions
This file was deleted.

assets/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This folder contains several support files for the GitHub repository and
2+
for other development needs.

assets/fontello.zip

29.5 KB
Binary file not shown.

assets/header.png

21.2 KB
Loading

assets/logo.png

-13.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)