documentation 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ee69981e399c23b45190208a36587d22ef937fa
4
- data.tar.gz: c681d1aa01d8d237697e5fd742cfb26620f11f74
3
+ metadata.gz: 3ca8ff1ae21b1a4805879ab5fd9ba8872a1e4dbf
4
+ data.tar.gz: 2324af24ba636e1820395d9dbe23b50c8c6d0526
5
5
  SHA512:
6
- metadata.gz: b73915ea29d76182c81f0b8f2aee4986bdbbf0794c08a4571817df2539405cabe4658521c31f963c053f81dac9dbc490eac724446c85f18f995a2f966b44c670
7
- data.tar.gz: ac5424d483dff52ec3e1ec9dcb5a05a7e3c99a1e34282009667626972bcb59cda977251506465ac7b26c2e9492db45f3fc8bda33d152329cfc3a7493e10887b1
6
+ metadata.gz: 937486cd5bb4a2e0901a829f0dbbcb4cdca775ec50e3dfba7b08b0305ac8c8d17946a30cd894458b6b052e1dca46b36e58d1164379076b0bc91136e89db9a536
7
+ data.tar.gz: d5b492b62ce755e2f886e768c51709eb09f21298d97c4dadbab6db41cfa8c416ceb1adce696fc101b6d4b6d7e59cbc06c8bccd55783f8ce1e735f558c4a4bb9f
@@ -0,0 +1,37 @@
1
+ By default, all pages you create will be visible & editable by anyone. In order to add a level of authorisation, you can define an **Authorizer** what level of access is given to each request.
2
+
3
+ ## Creating an authorizer class
4
+
5
+ To do this, begin by creating a new class which inherits from `Documentation::Authorizer`.
6
+
7
+ ```ruby
8
+ class MyDocsAuthorizer < Documentation::Authorizer
9
+ end
10
+ ```
11
+
12
+ Once you have created this class, you can define a number of methods. In all your methods you can access `controller` to access the controller which requested the page. This allows you to access sessions, params or other request information. The methods you can override are as follows:
13
+
14
+ * `can_use_ui?` - whether the built-in UI can be used
15
+ * `can_search?` - whether searching can take place
16
+ * `can_view_page?(page)` - whether the provided page can be viewed
17
+ * `can_add_page?(page)` - whether a page can be created within the provided page
18
+ * `can_reposition_page?(page)` - whether pages within the provided page can be repositioned
19
+ * `can_edit_page?(page)` - whether the provided page can be edited
20
+ * `can_delete_page?(page)` - whether the provided page can be deleted
21
+ * `can_upload?(page)` - whether a file can be uploaded to this page
22
+
23
+ The default for all these method if left un-defined, is `true`. Here's an example:
24
+
25
+ ```ruby
26
+ def can_edit_page?(page)
27
+ controller.request['rack.current_user'].admin?
28
+ end
29
+ ```
30
+
31
+ ## Using your authorizer class
32
+
33
+ Once you have created your class, you should tell Documentation that it should use it. Do this by adding the following to your `config/initializers/documentation.rb` file`.
34
+
35
+ ```ruby
36
+ Documentation.config.authorizer = MyDocsAuthorizer
37
+ ```
@@ -0,0 +1,38 @@
1
+ Everything you need to access the pages stored in the database can be found on the `Documentation::Page` model.
2
+
3
+ ## Finding pages
4
+
5
+ In most cases, you'll want to find a page based on its path from the root of the site, for example, `example/page/here` may be the string you want to use to find the `here` page.
6
+
7
+ ```ruby
8
+ page = Documentation::Page.find_from_path('example/page/here')
9
+ ```
10
+
11
+ ## Useful page methods
12
+
13
+ Once you've found a page, there are a number of methods & attribute which may be useful to you.
14
+
15
+ * `title` - the page's title
16
+ * `content` - the markdown content for a page
17
+ * `compiled_content` - the HTML content for a page
18
+ * `parents` - returns an array of all the parents for the page
19
+ * `breadcrumb` - returns the items which should be included in a breadcrumb trail
20
+ * `full_permalink` - the full permalink including all parents
21
+ * `children` - all child pages for the page
22
+ * `has_children?` - whether or not the page has children
23
+ * `navigation` - appropriate navigation pages for this page
24
+
25
+ ## Searching
26
+
27
+ If you wish to search pages, you should use the `Documentation::Page.search` method as shown below:
28
+
29
+ ```ruby
30
+ result = Documentation::Page.search('query here', :page => 1)
31
+ ```
32
+
33
+ Once you have a result object, you can use this to get information about the pages which matched the result. The following methods may be useful:
34
+
35
+ * `results` - the pages which have been found
36
+ * `excerpt_for(page)` - an excerpt to display for this page
37
+ * `empty?` - was the search empty?
38
+ * `total_pages` - the total number of pagination pages
@@ -0,0 +1,105 @@
1
+ All the helpers needed to do this are provided for you and are shown below. These are the same helpers which are used in the built-in interface.
2
+
3
+ -------------
4
+
5
+ ### `documentation_breadcrumb_for(page)`
6
+
7
+ This helper will return an unordered list containing a breadcrumb trail for the page you provide. The output will look something like this:
8
+
9
+ ```html
10
+ <nav class='breadcrumb'>
11
+ <ul>
12
+ <li><a href='/'>Home</a></li>
13
+ <li><a href='/example'>Example</a></li>
14
+ <li><a href='/example/page'>Page</a></li>
15
+ </ul>
16
+ </nav>
17
+ ```
18
+
19
+ #### Options for this helper
20
+
21
+ * `:class` - allows you to set the class for the outer nav element. Defaults to 'breadcrumb'.
22
+ * `:root_link` - sets the text for the first link in the breadcrumb. Defaults to 'Home' (taken from the i18n). Set to false to exclude this item.
23
+
24
+ -------------
25
+
26
+ ### `documentation_navigation_tree_for(page)`
27
+
28
+ Provides a single-level nested unordered list which contains the given page. If the given page has no children, its parents will be included. If it has children, they will be shown too. The active page will include the `active` class.
29
+
30
+ ```html
31
+ <ul>
32
+ <li><a href='/example'>Example Section</a></li>
33
+ <li>
34
+ <a href='/food'>Information about food</a>
35
+ <ul>
36
+ <li><a href='/foot/fruit'>Fruit</a></li>
37
+ <li><a href='/foot/vegetables' class='active'>Vegetables</a></li>
38
+ <li><a href='/foot/meat'>Meat</a></li>
39
+ </ul>
40
+ </li>
41
+ <li><a href='/drink'>Information about drink</a></li>
42
+ </ul>
43
+ ```
44
+
45
+ -------------
46
+
47
+ ### `documentation_content_for(page)`
48
+
49
+ Renders the content for a given page. This will deal with ensuring that the page is unescaped and that any formatting options are correctly parsed.
50
+
51
+ -------------
52
+
53
+ ### `documentation_authorizer`
54
+
55
+ Returns the documentation authorizer.
56
+
57
+ -------------
58
+
59
+ ### `documentation_edit_page_path(page)`
60
+
61
+ Returns the path to edit the given page in the provided UI.
62
+
63
+ -------------
64
+
65
+ ### `documentation_page_path(page)`
66
+
67
+ Returns the path to view the given page in the provided UI.
68
+
69
+ -------------
70
+
71
+ ### `documentation_search_summary(result)`
72
+
73
+ Returns information about your search result
74
+
75
+ -------------
76
+
77
+ ### `documentation_search_results(result, options)`
78
+
79
+ Return an unordered list containing your search results.
80
+
81
+ ```html
82
+ <ul class='searchResults'>
83
+ <li>
84
+ <h4><a href='path/to/page'>Title of page</a></h4>
85
+ <p class='in'><!--- Other pages if they exist --></p>
86
+ <p class='except'>An excerpt goes <mark>here</mark></p>
87
+ </li>
88
+ </ul>
89
+ ```
90
+
91
+ #### Options for this helper
92
+
93
+ * `:class` - the class for the outer list
94
+
95
+ -------------
96
+
97
+ ### `documentation_search_pagination(result, options)`
98
+
99
+ Return a next page and previous page link based on the results
100
+
101
+ #### Options for this helper
102
+
103
+ * `:link_class` - the class to apply to both links
104
+ * `:next_link_class` - the class for the next link
105
+ * `:previous_link_class` - the class for the previous link
@@ -0,0 +1,3 @@
1
+ In many cases, it may be easier to build your own views and use the built-in interface for admin actions. The library provides a number of helpers and useful model methods allowing you to easily access content and render it without much effort at all.
2
+
3
+ {{nav}}
@@ -0,0 +1,9 @@
1
+ As with all Rails engines, you can customize every aspect of the engine within your Rails application.
2
+
3
+ ## Overriding views
4
+
5
+ You can override views by simply placing new view files in your `app/views` folder. You can see the files which exist and can be overridden in [our views directory](https://github.com/adamcooke/documentation/tree/master/app/views). We use Haml for our views but you can use whatever you want when overriding.
6
+
7
+ ## Internationalization
8
+
9
+ The interface pulls all its wording from the Rails i18n system. This means you can simply override any wording in your own locale files. The keys available can be found in [our en.yml file](https://github.com/adamcooke/documentation/blob/master/config/locales/en.yml).
@@ -0,0 +1,20 @@
1
+ **Welcome to Documentation.** You can go ahead and delete this page whenever you're ready. It contains some information as well as being a good reference point for how things will be styled. Every page in Documentation is formatted with Markdown (although there are a couple of additions which are demonstrated here).
2
+
3
+ ## Features
4
+
5
+ * A simple & attractive interface for viewing & editing your pages
6
+ * Store pages in a hierarchy
7
+ * Modular authorisation architecture
8
+ * Modular search backend architecture
9
+ * Full i18n support
10
+ * Override any views as necessary within your Rails application
11
+
12
+ Recommendation: Take a look through all the pages in this guide while developing your application. If you delete this section, you can always re-add it by running `rake documentation:install_guides` from the root of your Rails application.
13
+
14
+ ## Useful links
15
+
16
+ The links below provide you with easy access to key resources which will help you.
17
+
18
+ * [Browse source code on GitHub](https://github.com/adamcooke/documentation)
19
+ * [View issues](https://github.com/adamcooke/documentation/issues)
20
+ * [Check out the installation guide](https://github.com/adamcooke/documentation/blob/master/README.md)
@@ -0,0 +1,17 @@
1
+ By default, Documentation uses a very very simple search which uses a LIKE query on your database. As this method is far from ideal, Documentation allows additional search backends to be created.
2
+
3
+ ## Elasticsearch
4
+
5
+ The recommended method of indexing & searching data is to use Elasticsearch. A module is provided for this [on GitHub](https://github.com/adamcooke/documentation-elasticsearch) and can be installed by following the instructions on the repo's README page.
6
+
7
+ ## Creating your own search backend
8
+
9
+ To create your own backend, create a new class which inherits from `Documentation::Searchers::Abstract`. This class must confirm to the protocol outlined in this [abstract.rb](https://github.com/adamcooke/documentation/blob/master/lib/documentation/searchers/abstract.rb) file.
10
+
11
+ ## Using your custom backend
12
+
13
+ Once you have created a backend, you should tell Documentation to use it. Just add the following to your `config/initializers/documentation.rb` file.
14
+
15
+ ```ruby
16
+ Documentation.config.searcher = MyCustomSearcher.new
17
+ ```
@@ -0,0 +1,37 @@
1
+ Pages all use standard Markdown markup to format them. There are some additional options though which you may find useful:
2
+
3
+ ## Linking to other pages
4
+
5
+ If you need to link to other documentation pages, it is important to use the following syntax to ensure the link is maintain regardless of how the page is rendered.
6
+
7
+ * `[Page](^permalink)` - links from a child of the page where the link is shown
8
+ * `[Page](^./permalink)` - links from a sibling of the page where the link is shown
9
+ * `[Page](^/permalink) `- links from the root page
10
+
11
+ It is important to ensure the `^` character is maintained.
12
+
13
+ ## Code Highlighting
14
+
15
+ Code highlighting is handled by [Pygments](http://pygments.org/). This is a Python library and you may need to install it. Fortunately, installing it is usually as simple as running:
16
+
17
+ ```text
18
+ easy_install pygments
19
+ ```
20
+
21
+ ## Recommendations & Warnings
22
+
23
+ Any paragraph which is prefixed with `Recommendation:` or `Warning:` will be styled as appropriate. Recommendations are displayed with an information icon and a blue background and warnings are displayed with a warning icon and a yellow background. As shown below:
24
+
25
+ Recommendation: This is an example recommendation
26
+
27
+ Warning: This is an example warning.
28
+
29
+ ## Images
30
+
31
+ If you are embedding images, it is usually best to embed them in the centre of the page. To do to this, simply use the following Markdown:
32
+
33
+ ```text
34
+ ![My image*center](path/to/image.png)
35
+ ```
36
+
37
+ This will embed the image in a `imgcontainer` element with the `center` class. The stylesheet will then take care of the rest.
@@ -1,3 +1,3 @@
1
1
  module Documentation
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-30 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -254,6 +254,14 @@ files:
254
254
  - db/migrate/20140724111844_create_nifty_attachments_table.rb
255
255
  - db/migrate/20140724114255_create_documentation_screenshots.rb
256
256
  - db/seeds.rb
257
+ - doc/developers-guide/authorization.md
258
+ - doc/developers-guide/building-views/accessing-pages.md
259
+ - doc/developers-guide/building-views/helpers.md
260
+ - doc/developers-guide/building-views/overview.md
261
+ - doc/developers-guide/customization.md
262
+ - doc/developers-guide/overview.md
263
+ - doc/developers-guide/search-backends.md
264
+ - doc/markdown/overview.md
257
265
  - lib/documentation.rb
258
266
  - lib/documentation/authorizer.rb
259
267
  - lib/documentation/config.rb