Skip to content
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

Example usage snippits on landing page #293

Open
wants to merge 6 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ exclude:
- Gemfile.lock

markdown: kramdown
kramdown:
input: GFM
11 changes: 11 additions & 0 deletions _includes/example-usage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<section class="layout layout--light">
<section class="content content--small">
<h1>Example Usage</h1>
{% render_markdown example.md %}
<footer class="content__footer">
<a class="button" href="https://github.com/thoughtbot/ember-cli-rails">
Full Documentation
</a>
</footer>
</section>
</section>
104 changes: 104 additions & 0 deletions _includes/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
First, generate the gem's initializer:

```bash
$ rails generate ember:init
```

This will create the following initializer:

```ruby
# config/initializers/ember.rb

EmberCli.configure do |c|
c.app :frontend
end
```

The initializer assumes that your Ember application exists in
`Rails.root.join("frontend")`.

If this is not the case, you could

* move your existing Ember application into `Rails.root.join("frontend")`
* configure `frontend` to look for the Ember application in its current
directory:

```rb
c.app :frontend, path: "~/projects/my-ember-app"
```

* generate a new Ember project:

```bash
$ ember new frontend --skip-git
```

**Initializer options**

- `name` - this represents the name of the Ember CLI application.

- `path` - the path where your Ember CLI application is located. The default
value is the name of your app in the Rails root.

```ruby
EmberCli.configure do |c|
c.app :adminpanel # path defaults to `Rails.root.join("adminpanel")`
c.app :frontend,
path: "/path/to/your/ember-cli-app/on/disk"
end
```

Next, install the [ember-cli-rails-addon][addon]:

```bash
$ cd path/to/frontend
$ ember install ember-cli-rails-addon
```

Be sure that the addon's [`MAJOR` and `MINOR` version][semver] matches the gem's
`MAJOR` and `MINOR` versions.

For instance, if you're using the `0.6.x` version of the gem, specify
`~> 0.6.0` in your Ember app's `package.json`:

```json
{
"devDependencies": {
"ember-cli-rails-addon": "~> 0.6.0"
}
}
```

[addon]: https://github.com/rondale-sc/ember-cli-rails-addon/
[semver]: http://semver.org/

Next, configure Rails to route requests to the `frontend` Ember application:

```rb
# config/routes.rb

Rails.application.routes.draw do
mount_ember_app :frontend, to: "/"
end
```

Ember requests will be set `params[:ember_app]` to the name of the application.
In the above example, `params[:ember_app] == :frontend`.

**Routing options**

* `to` - The path to handle as an Ember application. This will only apply to
`format: :html` requests. Additionally, this will handle child routes as well.
For instance, mounting `mount_ember_app :frontend, to: "/frontend"` will handle a
`format: :html` request to `/frontend/posts`.
* `controller` - Defaults to `"ember_cli/ember"`
* `action` - Defaults to `"index"`

Finally, install your Ember application's dependencies:

```bash
$ rake ember:install
```

Boot your Rails application, navigate to `"/"`, and view your EmberCLI
application!
28 changes: 28 additions & 0 deletions _plugins/render-markdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Jekyll
class RenderMarkdownTag < Liquid::Tag
require "kramdown"

def initialize(tag_name, text, tokens)
super
@text = text.strip
end

def render(context)
site = context.registers[:site]

Kramdown::Document.new(parsed_markdown(site)).to_html
end

private

def parsed_markdown(site)
(Liquid::Template.parse markdown_file).render(site.site_payload)
end

def markdown_file
File.read(File.join(Dir.pwd, "_includes", @text))
end
end
end

Liquid::Template.register_tag('render_markdown', Jekyll::RenderMarkdownTag)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

24 changes: 24 additions & 0 deletions _sass/_code.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.code {
background-color: $code-background-color;
border: solid 1px $code-border-color;
border-radius: $base-border-radius;
font-size: $base-font-size * 1.1;
margin-bottom: 2.5rem;

@media (min-width: $medium-screen) {
margin-bottom: 4rem;
}
}

.code__header {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selector code__header should be written in lowercase with hyphens

background-color: $code-header-background-color;
color: darken($code-header-background-color, 40%);
overflow-x: scroll;
padding: 0.75rem 1rem 1rem;
}

.code__body {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selector code__body should be written in lowercase with hyphens

margin: 0;
overflow-x: scroll;
padding: 0 1rem;
}
1 change: 1 addition & 0 deletions _sass/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

.content__footer {
@include margin(1rem null);
text-align: center;
width: 100%;

@media (min-width: $medium-screen) {
Expand Down
Loading