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

Knowledge base page #50

Open
wants to merge 5 commits into
base: master
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ Go on! Test this out, run the above command to see that it is OK.
rake
```

### Step 4. Run the Rails server and enjoy...
### Step 4. Create and populate the database

```bash
rake db:create;rake db:migrate;rake db:seed
```


### Step 5. Run the Rails server and enjoy...

```bash
bin/rails s
Expand Down
11 changes: 11 additions & 0 deletions app/assets/stylesheets/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ ul.members-list li span.name {
font-weight: bold;
}

.sort_header {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 10px;
background: #373737;
color: #fff;
}

.sort_header:hover, .sort_header:focus {
text-decoration: underline;
}

19 changes: 19 additions & 0 deletions app/controllers/knowledge_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class KnowledgeController < ApplicationController

def index
@presentations = Presentation.all
if params[:sort_by] == 'title'
@presentations = @presentations.sort {|ppt1, ppt2| ppt1.title <=> ppt2.title}
elsif params[:sort_by] == 'date'
@presentations = @presentations.sort {|ppt1, ppt2| ppt1.date_presented <=> ppt2.date_presented}
elsif params[:sort_by] == 'presentor'
@presentations = @presentations.sort {|ppt1, ppt2| ppt1.presentor <=> ppt2.presentor}
end
end

private

def presentation_params
params.require(:presentation).permit(:title, :url, :presentor, :date_presented)
end
end
3 changes: 3 additions & 0 deletions app/models/presentation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Presentation < ActiveRecord::Base
# attr_accessible :title, :url, :description, :date_presented
end
29 changes: 29 additions & 0 deletions app/views/knowledge/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<%

@current_page = "knowledge"
@title = ""

%>

<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<p>We like open-source. We also like Ruby and Rails framework. We love fiddling around with technology.</p>
<p>This is the very reason we want our knowledge base to be open for everyone</p>
<p>Below, you can find our presentations, up until now</p>

<table>
<tr>
<th><%= link_to 'Title', {:controller => 'knowledge', :action => 'index', :sort_by => 'title'}, :class => 'sort_header'%></th>
<th><%= link_to 'Date', {:controller => 'knowledge', :action => 'index', :sort_by => 'date'}, :class => 'sort_header'%></th>
<th><%= link_to 'Details', {:controller => 'knowledge', :action => 'index', :sort_by => 'presentor'}, :class => 'sort_header'%></th>
</tr>
<% @presentations.each do |presentation|%>
<tr>
<td><%= link_to presentation.title, presentation.url %></td>
<td><%= presentation.date_presented.strftime("%d/%m/%Y") %></td>
<td>Presented by <%= presentation.presentor %>.</td>
</tr>
<% end %>
</table>
</section>
</div>
21 changes: 14 additions & 7 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@
<h2 id="project_tagline">Official Thessaloniki Ruby Meetup Home</h2>

<section id="menu">
<% if @current_page == 'home' %>
<span class="current">Home</span>
<a class="" href="members">Members</a>
<% elsif @current_page == 'members' %>
<a class="" href="/">Home</a>
<span class="current">Members</span>
<% end %>
<% case @current_page
when 'home' %>
<span class="current">Home</span>
<a class="" href="members">Members</a>
<a class="" href="knowledge">Knowledge Base</a>
<% when 'members' %>
<a class="" href="/">Home</a>
<span class="current">Members</span>
<a class="" href="knowledge">Knowledge Base</a>
<% when 'knowledge' %>
<a class="" href="/">Home</a>
<a class="" href="members">Members</a>
<span class="current" href="knowledge">Knowledge Base</span>
<% end %>
</section>
</header>
</div>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Rails.application.routes.draw do
root 'home#index'
get 'members', :to => 'members#index'
get 'knowledge', :to => 'knowledge#index'



Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20150101_create_presentations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CreatePresentations < ActiveRecord::Migration
def up
create_table :presentations do |t|
t.string :title
t.string :url
t.datetime :date_presented
t.text :presentor
end
end

def down
drop_table :presentations
end
end
23 changes: 23 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150101) do

create_table "presentations", force: true do |t|
t.string "title"
t.string "url"
t.datetime "date_presented"
t.text "presentor"
end

end
19 changes: 19 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,22 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)

# TODO: Add presentation details here
presentations = [{:title => 'git and GitHub', :url => 'https://github.com/thessrb/meetup/blob/master/meetups/2/presentations/gitAndGithub/AppCampGr2011Preso.pdf?raw=true', :date_presented => '06/09/2011', :presentor => 'Petros Amiridis'},
{:title => 'Simple Web Apps with Sinatra', :url => 'http://prezi.com/de5yqj9sa9zq/simple-webapps-with-sinatra/', :date_presented => '06/09/2011', :presentor => 'Vassilis Rizopoulos'},
{:title => "Ruby Gems are Pragmatic Programmer's Best Friends", :url => 'https://github.com/thessrb/meetup/blob/master/meetups/3/Ruby%2Bgems%2Bare%2Bpragmatic%2Bprogrammer%2527s%2Bbest%2Bfriends.pdf', :date_presented => '01/11/2011', :presentor => 'Konstantinos Kostopoulos'},
{:title => 'Codigia - a dispersed team example', :url => 'https://github.com/thessrb/meetup/blob/master/meetups/4/presentations/Codigia-DispersedTeamExample/meetup_4_slides.pdf', :date_presented => '29/11/2011', :presentor => 'Stefanos Togoulidis'},
{:title => 'Introduction to configuration management with Puppet', :url => 'https://speakerdeck.com/robbyt/introduction-to-puppet', :date_presented => '24/09/2013', :presentor => 'Robert Terhaar'},
{:title => 'Introduction to Functional Programming with Elixir', :url => 'https://docs.google.com/presentation/d/1Bku0-9Eu9k_lTMnAQOYpsbiRGlSaMXxo_7MPEl7bm0s/edit?pli=1#slide=id.p', :date_presented => '29/10/2013', :presentor => 'Vassilis Rizopoulos'},
{:title => 'Decreasing technical debt with SonarQube', :url => 'http://www.slideshare.net/ppapapetrou/thessaloniki-rb24', :date_presented => '28/01/2014', :presentor => 'Patroklos Papapetrou'},
{:title => 'Lambda calculus for programmers', :url => 'https://drive.google.com/file/d/0B2yeyDGqvZRQTnpxRmRjYTVQRnM/edit?usp=sharing', :date_presented => '18/02/2014', :presentor => 'Kostas Lolas'},
{:title => 'Agile Methodologies — Manage and code without losing your head', :url => 'https://speakerdeck.com/krap/agile-methodologies-manage-and-code-without-losing-your-head', :date_presented => '18/03/2014', :presentor => 'Apostolos Kritikos'},
{:title => 'Ruby Basics', :url => 'http://xarisd.io/presentations/ruby-basics-ii/#/', :date_presented => '19/06/2014', :presentor => 'Haris Dimitriou'},
{:title => 'Introduction to Ruby on Rails', :url => 'https://speakerdeck.com/petros/thessaloniki-ruby-meetup-and-rubyzino-number-30', :date_presented => '30/09/2014', :presentor => 'Petros Amiridis'},
{:title => 'Create the first pages of our Rails app and deploy to Heroku', :url => 'http://xarisd.io/presentations/rails-basics-01/#/', :date_presented => '25/10/2014', :presentor => 'Haris Dimitriou'},
]

presentations.each do |presentation|
Presentation.create!(presentation)
end