Skip to content

Commit 517ac84

Browse files
Begin Contribution Documentation
1 parent 713b8e2 commit 517ac84

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

app/assets/stylesheets/application.css

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ h1 {
2626
a {
2727
text-decoration: none;
2828
color: black;
29+
border-bottom: 1px solid black;
2930
}
3031

3132
/* DOCUMENTATION */
@@ -100,6 +101,13 @@ pre code {
100101
border: none;
101102
}
102103

104+
blockquote {
105+
padding-left: 16px;
106+
color: #9197a1;
107+
margin: 0;
108+
border-left: 3px solid #9ca3af;
109+
}
110+
103111
.highlight {
104112
background-color: rgba(var(--color-light-gray), 0.5);
105113
border: 1px solid rgba(var(--color-light-gray), 1);

app/markdown/contribution.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Contribution
2+
So you're interested in contributing to PureChart? Excellent - we're grateful for the help!
3+
4+
## Create Example Project
5+
We recommend creating a simple project to test your work.
6+
7+
> Note that we're using Ruby `3.0.0` and Rails `7.0.8`. If you encounter unexpected errors, try using these versions instead.
8+
9+
First, choose the directory where you will be working and run `rails new metrics` to generate a new Ruby on Rails project. We've called the application "metrics" because one might use our charts for some kind of analytics application, but you may choose whatever name you'd like.
10+
11+
## Clone PureChart
12+
Next, clone the PureChart gem from GitHub in the same directory (not in `/metrics`) as so -
13+
14+
```sh
15+
git clone https://github.com/PureChart/purechart.git
16+
```
17+
18+
## Add PureChart to Project
19+
Let's add the local version of PureChart to the metrics application. Open `metrics/Gemfile` and add the following line somewhere in the file.
20+
21+
#### metrics/Gemfile
22+
```ruby
23+
gem "purechart", path: "../purechart"
24+
```
25+
26+
Move to the `metrics` directory in your terminal and run `bundle install` to install the gem. Finally, run `bin/rails server` and you're ready to go! If you visit `http://127.0.0.1:3001` in your web browser, you'll see the following webpage -
27+
28+
![Rails Default Webpage](./images/other/RailsDefaultWebpage.png)
29+
30+
## Create a Chart
31+
Now that we have a working test project, let's add a new page called "dashboard." Ruby on Rails provides many nice generator commands, and we'll use one of them right now. But first, open `metrics/config/routes.rb`. It should look like this -
32+
33+
#### metrics/config/routes.rb
34+
```ruby
35+
Rails.application.routes.draw do
36+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
37+
38+
# Defines the root path route ("/")
39+
# root "articles#index"
40+
end
41+
```
42+
43+
This contains all the routes our application will handle. Add a new route that will point to our dashboard page -
44+
45+
#### metrics/config/routes.rb
46+
```ruby
47+
Rails.application.routes.draw do
48+
get "/dashboard", to: "dashboard#index"
49+
...
50+
end
51+
```
52+
53+
Finally, run `bin/rails generate controller Articles index --skip-routes` to create a **controller** for the dashboard. Ruby on Rails uses the MVC model, which stands for **M**odel **V**iew **C**ontroller. Long story short, the controller decides what data to collect and what views to render based on a user request. The `--skip-routes` flag at the end is necessary because we've already added the route manually.
54+
55+
> [RAILSG](https://railsg.xyz/) is an awesome website that helps you build Ruby on Rails generator commands. Definitely give it a whirl at some point.
56+
57+
This will create a few new files. We're most interested in...
58+
59+
- The controller (`app/controllers/dashboard_controller.rb`), and
60+
- The view (`app/views/dashboard/index.htmk.erb`).

app/views/articles/index.html.erb

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<%= button_tag "Getting Started", id: "getting-started", class: "nav-button getting-started", data: { action: "click->articles--page#navigate" } %>
1414
<%= button_tag "Types of Charts", id: "types-of-charts", class: "nav-button types-of-charts", data: { action: "click->articles--page#navigate" } %>
1515
<%= button_tag "Chart Styling", id: "chart-styling", class: "nav-button chart-styling", data: { action: "click->articles--page#navigate" } %>
16+
<%= button_tag "Contribution", id: "contribution", class: "nav-button contribution", data: { action: "click->articles--page#navigate" } %>
1617
</div>
1718
</div>
1819

1.24 MB
Loading

0 commit comments

Comments
 (0)