-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move documentation into main repository #363
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
$blue: #53adc6; | ||
$red: #cf726e; | ||
$green: #5bc89e; | ||
$white: #f0f0f0; | ||
|
||
$code-black: #202020; | ||
$code-white: #e0e0dc; | ||
$code-green: #b0bf82; | ||
$code-blue: #8fbdcc; | ||
$code-yellow: #f8d29d; | ||
$code-red: #b95c56; | ||
|
||
html, | ||
body { | ||
font-family: 'Lato', serif; | ||
font-size: 18px; | ||
line-height: 1.62em; | ||
margin: 0; | ||
} | ||
|
||
img { | ||
max-width: 100%; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3 { | ||
font-family: 'Fjalla One', sans-serif; | ||
margin-top: 2em; | ||
} | ||
|
||
a { | ||
color: $blue; | ||
text-decoration: none; | ||
} | ||
|
||
.content { | ||
margin-bottom: 2em; | ||
margin-left: auto; | ||
margin-right: auto; | ||
margin-top: 2em; | ||
width: 60em; | ||
|
||
.sidebar { | ||
float: left; | ||
width: 20em; | ||
|
||
&-links { | ||
list-style: none; | ||
padding-left: 0; | ||
} | ||
} | ||
|
||
.main { | ||
float: right; | ||
width: 40em; | ||
} | ||
} | ||
|
||
.flash-wrapper { | ||
background-color: $red; | ||
color: $white; | ||
padding: 1em; | ||
|
||
.flash { | ||
margin-left: auto; | ||
margin-right: auto; | ||
width: 40em; | ||
} | ||
} | ||
|
||
code { | ||
font-family: "Source Code Pro"; | ||
font-size: 0.8rem; | ||
padding: 0.4em 0.2em 0; | ||
|
||
&.hljs { | ||
background-color: $code-black; | ||
color: $code-white; | ||
padding-left: 1rem; | ||
|
||
.hljs-string { color: $code-green; } | ||
.hljs-constant { color: $code-blue; } | ||
.hljs-symbol { color: $code-red; } | ||
.hljs-keyword { color: $code-yellow; } | ||
|
||
.hljs-title, | ||
.hljs-parent { color: $code-blue; } | ||
|
||
.hljs-tag { color: $code-yellow; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class DocsController < ApplicationController | ||
def index | ||
render file: "README" | ||
end | ||
|
||
def show | ||
render file: "docs/#{params[:page]}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<html> | ||
<head> | ||
<%= stylesheet_link_tag "docs", media: "all" %> | ||
<link href='//fonts.googleapis.com/css?family=Lato|Source+Code+Pro|Fjalla+One' rel='stylesheet' type='text/css'> | ||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/default.min.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="content"> | ||
<div class="sidebar"> | ||
<h1>Administrate</h1> | ||
|
||
<ul class="sidebar-links"> | ||
<li><a href="/">Home</a></li> | ||
<li><a href="https://github.com/thoughtbot/administrate/issues/new">Feedback</a></li> | ||
</ul> | ||
|
||
<h3>Documentation</h3> | ||
|
||
<ul class="sidebar-links"> | ||
<li><a href="/">README</a></li> | ||
<li><a href="/getting_started">Getting Started</a></li> | ||
<li><a href="/customizing_dashboards">Customizing Dashboards</a></li> | ||
<li><a href="/customizing_page_views">Customizing Page Views</a></li> | ||
<li><a href="/customizing_attribute_partials">Customizing Attribute Partials</a></li> | ||
<li><a href="/adding_custom_field_types">Adding Custom Field Types</a></li> | ||
<li><a href="/customizing_controller_actions">Customizing Controller Actions</a></li> | ||
</ul> | ||
</div> | ||
|
||
<div class="main"> | ||
<%= yield %> | ||
</div> | ||
</div> | ||
|
||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script> | ||
<script>hljs.initHighlightingOnLoad();</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Adding Custom Field Types | ||
|
||
If your application deals with a nonstandard data type, | ||
you can create an `Administrate::Field` object to help display | ||
the custom data type across the dashboard. | ||
|
||
`Administrate::Field` objects consist of two parts: | ||
a Ruby class and associated views. | ||
|
||
For example, let's create a `Field` that displays [Gravatars] based on an email. | ||
|
||
[Gravatars]: https://gravatar.com/ | ||
|
||
First, we'll run a generator to set us up with the files we need: | ||
|
||
```bash | ||
rails generate administrate:field gravatar | ||
``` | ||
|
||
This creates a few files: | ||
|
||
- `app/fields/gravatar_field.rb` | ||
- `app/views/fields/gravatar_field/_show.html.erb` | ||
- `app/views/fields/gravatar_field/_index.html.erb` | ||
- `app/views/fields/gravatar_field/_form.html.erb` | ||
|
||
We can edit the `app/fields/gravatar_field.rb` to add some custom logic: | ||
|
||
```ruby | ||
# app/fields/gravatar_field.rb | ||
require 'digest/md5' | ||
|
||
class GravatarField < Administrate::Field::Base | ||
def gravatar_url | ||
email_address = data.downcase | ||
hash = Digest::MD5.hexdigest(email_address) | ||
"http://www.gravatar.com/avatar/#{hash}" | ||
end | ||
end | ||
``` | ||
|
||
Next, we can customize the partials to display data how we'd like. | ||
Open up the `app/views/fields/gravatar_field/_show.html.erb` partial. | ||
By default, it looks like: | ||
|
||
```eruby | ||
<%= field.data %> | ||
``` | ||
|
||
Since we want to display an image, we can change it to: | ||
|
||
```eruby | ||
<%= image_tag field.gravatar_url %> | ||
``` | ||
|
||
You can customize the other generated partials in the same way | ||
for custom behavior on the index and form pages. | ||
|
||
[Customizing Attribute Partials]: /customizing_attribute_partials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Customizing attribute partials | ||
|
||
Occasionally you might want to change how specific types of attributes appear | ||
across all dashboards. | ||
For example, you might want all `Number` values to round to three decimal points. | ||
|
||
To get started, run the appropriate rails generator: | ||
|
||
```bash | ||
rails generate administrate:views:field number | ||
``` | ||
|
||
This will generate three files: | ||
|
||
- `app/view/fields/form/_number.html.erb` | ||
- `app/view/fields/index/_number.html.erb` | ||
- `app/view/fields/show/_number.html.erb` | ||
|
||
The generated templates will have documentation | ||
describing which variables are in scope. | ||
The rendering part of the partial will look like: | ||
|
||
```eruby | ||
<%= field.data %> | ||
``` | ||
|
||
Changing numbers to display to three decimal places might look like this: | ||
|
||
```eruby | ||
<%= field.data.round(3) %> | ||
``` | ||
|
||
If you only want to change how an attribute appears | ||
on a single page (e.g. `index`), you may delete the unnecessary templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Customizing controller actions | ||
|
||
When you install Administrate into your app, | ||
we generate empty controllers for each of your resources. | ||
If you want to create more complex application behavior for a dashboard, | ||
simply overwrite controller actions. | ||
|
||
The generated controller will look something like: | ||
|
||
```ruby | ||
# app/controllers/admin/foos_controller.rb | ||
|
||
class Admin::FoosController < Admin::ApplicationController | ||
|
||
# Overwrite any of the RESTful controller actions to implement custom behavior | ||
# For example, you may want to send an email after a foo is updated. | ||
# | ||
# def update | ||
# foo = Foo.find(params[:id]) | ||
# foo.update(params[:foo]) | ||
# send_foo_updated_email | ||
# end | ||
|
||
# Override this method to specify custom lookup behavior. | ||
# This will be used to set the resource for the `show`, `edit`, and `update` | ||
# actions. | ||
# | ||
# def find_resource(param) | ||
# Foo.find_by!(slug: param) | ||
# end | ||
end | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alph-order