fixes & forums started
This commit is contained in:
263
README.rdoc
263
README.rdoc
@@ -1,261 +1,2 @@
|
||||
== Welcome to Rails
|
||||
|
||||
Rails is a web-application framework that includes everything needed to create
|
||||
database-backed web applications according to the Model-View-Control pattern.
|
||||
|
||||
This pattern splits the view (also called the presentation) into "dumb"
|
||||
templates that are primarily responsible for inserting pre-built data in between
|
||||
HTML tags. The model contains the "smart" domain objects (such as Account,
|
||||
Product, Person, Post) that holds all the business logic and knows how to
|
||||
persist themselves to a database. The controller handles the incoming requests
|
||||
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
||||
and directing data to the view.
|
||||
|
||||
In Rails, the model is handled by what's called an object-relational mapping
|
||||
layer entitled Active Record. This layer allows you to present the data from
|
||||
database rows as objects and embellish these data objects with business logic
|
||||
methods. You can read more about Active Record in
|
||||
link:files/vendor/rails/activerecord/README.html.
|
||||
|
||||
The controller and view are handled by the Action Pack, which handles both
|
||||
layers by its two parts: Action View and Action Controller. These two layers
|
||||
are bundled in a single package due to their heavy interdependence. This is
|
||||
unlike the relationship between the Active Record and Action Pack that is much
|
||||
more separate. Each of these packages can be used independently outside of
|
||||
Rails. You can read more about Action Pack in
|
||||
link:files/vendor/rails/actionpack/README.html.
|
||||
|
||||
|
||||
== Getting Started
|
||||
|
||||
1. At the command prompt, create a new Rails application:
|
||||
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
||||
|
||||
2. Change directory to <tt>myapp</tt> and start the web server:
|
||||
<tt>cd myapp; rails server</tt> (run with --help for options)
|
||||
|
||||
3. Go to http://localhost:3000/ and you'll see:
|
||||
"Welcome aboard: You're riding Ruby on Rails!"
|
||||
|
||||
4. Follow the guidelines to start developing your application. You can find
|
||||
the following resources handy:
|
||||
|
||||
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
||||
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
||||
|
||||
|
||||
== Debugging Rails
|
||||
|
||||
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
||||
will help you debug it and get it back on the rails.
|
||||
|
||||
First area to check is the application log files. Have "tail -f" commands
|
||||
running on the server.log and development.log. Rails will automatically display
|
||||
debugging and runtime information to these files. Debugging info will also be
|
||||
shown in the browser on requests from 127.0.0.1.
|
||||
|
||||
You can also log your own messages directly into the log file from your code
|
||||
using the Ruby logger class from inside your controllers. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def destroy
|
||||
@weblog = Weblog.find(params[:id])
|
||||
@weblog.destroy
|
||||
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
||||
end
|
||||
end
|
||||
|
||||
The result will be a message in your log file along the lines of:
|
||||
|
||||
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
||||
|
||||
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
||||
|
||||
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
||||
several books available online as well:
|
||||
|
||||
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
||||
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
||||
|
||||
These two books will bring you up to speed on the Ruby language and also on
|
||||
programming in general.
|
||||
|
||||
|
||||
== Debugger
|
||||
|
||||
Debugger support is available through the debugger command when you start your
|
||||
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
||||
execution at any point in the code, investigate and change the model, and then,
|
||||
resume execution! You need to install ruby-debug to run the server in debugging
|
||||
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
||||
|
||||
class WeblogController < ActionController::Base
|
||||
def index
|
||||
@posts = Post.all
|
||||
debugger
|
||||
end
|
||||
end
|
||||
|
||||
So the controller will accept the action, run the first line, then present you
|
||||
with a IRB prompt in the server window. Here you can do things like:
|
||||
|
||||
>> @posts.inspect
|
||||
=> "[#<Post:0x14a6be8
|
||||
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
||||
#<Post:0x14a6620
|
||||
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
||||
>> @posts.first.title = "hello from a debugger"
|
||||
=> "hello from a debugger"
|
||||
|
||||
...and even better, you can examine how your runtime objects actually work:
|
||||
|
||||
>> f = @posts.first
|
||||
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
||||
>> f.
|
||||
Display all 152 possibilities? (y or n)
|
||||
|
||||
Finally, when you're ready to resume execution, you can enter "cont".
|
||||
|
||||
|
||||
== Console
|
||||
|
||||
The console is a Ruby shell, which allows you to interact with your
|
||||
application's domain model. Here you'll have all parts of the application
|
||||
configured, just like it is when the application is running. You can inspect
|
||||
domain models, change values, and save to the database. Starting the script
|
||||
without arguments will launch it in the development environment.
|
||||
|
||||
To start the console, run <tt>rails console</tt> from the application
|
||||
directory.
|
||||
|
||||
Options:
|
||||
|
||||
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
||||
made to the database.
|
||||
* Passing an environment name as an argument will load the corresponding
|
||||
environment. Example: <tt>rails console production</tt>.
|
||||
|
||||
To reload your controllers and models after launching the console run
|
||||
<tt>reload!</tt>
|
||||
|
||||
More information about irb can be found at:
|
||||
link:http://www.rubycentral.org/pickaxe/irb.html
|
||||
|
||||
|
||||
== dbconsole
|
||||
|
||||
You can go to the command line of your database directly through <tt>rails
|
||||
dbconsole</tt>. You would be connected to the database with the credentials
|
||||
defined in database.yml. Starting the script without arguments will connect you
|
||||
to the development database. Passing an argument will connect you to a different
|
||||
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
||||
PostgreSQL and SQLite 3.
|
||||
|
||||
== Description of Contents
|
||||
|
||||
The default directory structure of a generated Ruby on Rails application:
|
||||
|
||||
|-- app
|
||||
| |-- assets
|
||||
| |-- images
|
||||
| |-- javascripts
|
||||
| `-- stylesheets
|
||||
| |-- controllers
|
||||
| |-- helpers
|
||||
| |-- mailers
|
||||
| |-- models
|
||||
| `-- views
|
||||
| `-- layouts
|
||||
|-- config
|
||||
| |-- environments
|
||||
| |-- initializers
|
||||
| `-- locales
|
||||
|-- db
|
||||
|-- doc
|
||||
|-- lib
|
||||
| `-- tasks
|
||||
|-- log
|
||||
|-- public
|
||||
|-- script
|
||||
|-- test
|
||||
| |-- fixtures
|
||||
| |-- functional
|
||||
| |-- integration
|
||||
| |-- performance
|
||||
| `-- unit
|
||||
|-- tmp
|
||||
| |-- cache
|
||||
| |-- pids
|
||||
| |-- sessions
|
||||
| `-- sockets
|
||||
`-- vendor
|
||||
|-- assets
|
||||
`-- stylesheets
|
||||
`-- plugins
|
||||
|
||||
app
|
||||
Holds all the code that's specific to this particular application.
|
||||
|
||||
app/assets
|
||||
Contains subdirectories for images, stylesheets, and JavaScript files.
|
||||
|
||||
app/controllers
|
||||
Holds controllers that should be named like weblogs_controller.rb for
|
||||
automated URL mapping. All controllers should descend from
|
||||
ApplicationController which itself descends from ActionController::Base.
|
||||
|
||||
app/models
|
||||
Holds models that should be named like post.rb. Models descend from
|
||||
ActiveRecord::Base by default.
|
||||
|
||||
app/views
|
||||
Holds the template files for the view that should be named like
|
||||
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
||||
eRuby syntax by default.
|
||||
|
||||
app/views/layouts
|
||||
Holds the template files for layouts to be used with views. This models the
|
||||
common header/footer method of wrapping views. In your views, define a layout
|
||||
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
||||
Inside default.html.erb, call <% yield %> to render the view using this
|
||||
layout.
|
||||
|
||||
app/helpers
|
||||
Holds view helpers that should be named like weblogs_helper.rb. These are
|
||||
generated for you automatically when using generators for controllers.
|
||||
Helpers can be used to wrap functionality for your views into methods.
|
||||
|
||||
config
|
||||
Configuration files for the Rails environment, the routing map, the database,
|
||||
and other dependencies.
|
||||
|
||||
db
|
||||
Contains the database schema in schema.rb. db/migrate contains all the
|
||||
sequence of Migrations for your schema.
|
||||
|
||||
doc
|
||||
This directory is where your application documentation will be stored when
|
||||
generated using <tt>rake doc:app</tt>
|
||||
|
||||
lib
|
||||
Application specific libraries. Basically, any kind of custom code that
|
||||
doesn't belong under controllers, models, or helpers. This directory is in
|
||||
the load path.
|
||||
|
||||
public
|
||||
The directory available for the web server. Also contains the dispatchers and the
|
||||
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
||||
server.
|
||||
|
||||
script
|
||||
Helper scripts for automation and generation.
|
||||
|
||||
test
|
||||
Unit and functional tests along with fixtures. When using the rails generate
|
||||
command, template test files will be generated for you and placed in this
|
||||
directory.
|
||||
|
||||
vendor
|
||||
External libraries that the application depends on. Also includes the plugins
|
||||
subdirectory. If the app has frozen rails, those gems also go here, under
|
||||
vendor/rails/. This directory is in the load path.
|
||||
== Redstoner.com
|
||||
I'm too lazy to write something here :D
|
||||
BIN
app/assets/images/bg.png
Normal file
BIN
app/assets/images/bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/assets/images/bg2.png
Normal file
BIN
app/assets/images/bg2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
BIN
app/assets/images/head_bg.png
Normal file
BIN
app/assets/images/head_bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1015 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 19 KiB |
@@ -1,6 +1,9 @@
|
||||
$(function(){
|
||||
|
||||
$('[data-confirm]').click(function(){
|
||||
var c = confirm($(this).attr('data-confirm'));
|
||||
if (!c) return false;
|
||||
})
|
||||
|
||||
$('#flash').delay(3000).fadeOut('slow');
|
||||
})
|
||||
@@ -10,8 +10,5 @@
|
||||
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
||||
// GO AFTER THE REQUIRES BELOW.
|
||||
//
|
||||
//= #require jquery
|
||||
//= #require jquery_ujs
|
||||
//= #require_tree .
|
||||
//= require jquery
|
||||
//= require confirm
|
||||
//= require app
|
||||
@@ -17,6 +17,10 @@ and (min-width: 1000px)
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
body {
|
||||
background-image: url('/assets/bg.png');
|
||||
}
|
||||
|
||||
a {
|
||||
transition: color 0.25s;
|
||||
color: $darkred;
|
||||
@@ -25,67 +29,39 @@ and (min-width: 1000px)
|
||||
color: #F00;
|
||||
}
|
||||
}
|
||||
#notice {
|
||||
background: #8e8;
|
||||
#flash {
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
border-bottom: 3px dashed #8d8;
|
||||
font-weight: bold;
|
||||
}
|
||||
#alert {
|
||||
background: #ebb;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
border-bottom: 3px dashed #fdd;
|
||||
font-weight: bold;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
&.notice {
|
||||
background: #8e8;
|
||||
border-bottom: 3px dashed #8d8;
|
||||
}
|
||||
&.alert {
|
||||
background: #ebb;
|
||||
border-bottom: 3px dashed #fdd;
|
||||
}
|
||||
}
|
||||
#head {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
background: $lightgrey;
|
||||
border-bottom: 10px solid $darkgrey;
|
||||
vertical-align: middle;
|
||||
font-weight: bold;
|
||||
box-shadow: 0 0 2px;
|
||||
z-index: 99;
|
||||
position: relative;
|
||||
width: 800px;
|
||||
margin: -10px auto 20px auto;
|
||||
padding: 20px 13px 13px 13px;
|
||||
background-image: url('/assets/head_bg.png');
|
||||
box-shadow: 0 0 10px -7px inset;
|
||||
border-bottom: 1px solid #fff;
|
||||
border-radius: 0 0 10px 10px;
|
||||
overflow: hidden;
|
||||
#logo {
|
||||
margin: 9px;
|
||||
margin-left: 20px;
|
||||
height: 32px;
|
||||
width: 32px;
|
||||
float: left;
|
||||
background: url('/assets/logo.png');
|
||||
}
|
||||
a {
|
||||
color: $midgrey;
|
||||
&:hover {
|
||||
color: $darkred;
|
||||
}
|
||||
}
|
||||
#menu {
|
||||
margin: auto;
|
||||
display: table;
|
||||
ul {
|
||||
float: left;
|
||||
margin-top: 0;
|
||||
li {
|
||||
float: left;
|
||||
height: 100%;
|
||||
margin: auto 10px;
|
||||
display: block;
|
||||
font-size: 2.3em;
|
||||
}
|
||||
}
|
||||
}
|
||||
#userinfo {
|
||||
float: right;
|
||||
padding: 0 10px;
|
||||
margin-top: 6px;
|
||||
text-align: right;
|
||||
&.logged-out {
|
||||
margin-top: 2px;
|
||||
}
|
||||
margin-top: 14px;
|
||||
img.avatar {
|
||||
border: 1px solid #000;
|
||||
border-radius: 16px;
|
||||
@@ -103,6 +79,30 @@ and (min-width: 1000px)
|
||||
line-height: 1em;
|
||||
}
|
||||
}
|
||||
a {
|
||||
color: $midgrey;
|
||||
&:hover {
|
||||
color: $darkred;
|
||||
}
|
||||
}
|
||||
#menu {
|
||||
width: 100%;
|
||||
background: url('/assets/head_bg.png') #fff;
|
||||
input {
|
||||
display: inline;
|
||||
}
|
||||
ul {
|
||||
float: left;
|
||||
margin-top: 0;
|
||||
li {
|
||||
float: left;
|
||||
height: 100%;
|
||||
margin: auto 10px;
|
||||
display: block;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
img.user-avatar {
|
||||
border: 1px solid #000;
|
||||
@@ -133,53 +133,50 @@ and (min-width: 1000px)
|
||||
|
||||
h1 {
|
||||
font-weight: normal;
|
||||
font-size: 400%;
|
||||
font-size: 200%;
|
||||
margin: 0;
|
||||
color: #888;
|
||||
text-shadow: 0 1px #999;
|
||||
}
|
||||
}
|
||||
|
||||
#posts {
|
||||
#post {
|
||||
margin-bottom: 50px;
|
||||
#post-title {
|
||||
margin-bottom: 10px;
|
||||
h2 {
|
||||
font-weight: normal;
|
||||
color: #700;
|
||||
text-transform: uppercase;
|
||||
display: inline;
|
||||
font-size: 250%;
|
||||
}
|
||||
.comment-counter {
|
||||
float: right;
|
||||
.post {
|
||||
margin-bottom: 50px;
|
||||
.post-title {
|
||||
margin-bottom: 10px;
|
||||
word-wrap: break-word;
|
||||
h2 {
|
||||
font-weight: normal;
|
||||
color: #700;
|
||||
text-transform: uppercase;
|
||||
display: inline;
|
||||
font-size: 200%;
|
||||
}
|
||||
.comment-counter {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
.post-info {
|
||||
border-bottom: 2px dashed #999;
|
||||
color: #888;
|
||||
a {
|
||||
color: #755;
|
||||
&:hover{
|
||||
color: #d55;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.post-info {
|
||||
border-bottom: 2px dashed #999;
|
||||
color: #888;
|
||||
a {
|
||||
color: #755;
|
||||
&:hover{
|
||||
color: #d55;
|
||||
.post-content {
|
||||
margin-top: 10px;
|
||||
clear: both;
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#post-content {
|
||||
margin-top: 10px;
|
||||
clear: both;
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
#comments {
|
||||
margin: 50px 0 0 40px;
|
||||
.comment {
|
||||
@@ -350,8 +347,34 @@ and (min-width: 1000px)
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
display: block;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
#forum_groups {
|
||||
.group {
|
||||
margin: 10px 0;
|
||||
.header {
|
||||
background: #ddd;
|
||||
border-radius: 5px 5px 0 0;
|
||||
padding: 5px 10px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
.forums {
|
||||
border: 1px solid #ddd;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
.forum {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
padding: 5px 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
6
app/controllers/forumgroups_controller.rb
Normal file
6
app/controllers/forumgroups_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class ForumgroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@groups = Forumgroup.all.sort{|s| s[:position]}
|
||||
end
|
||||
end
|
||||
2
app/controllers/forums_controller.rb
Normal file
2
app/controllers/forums_controller.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class ForumsController < ApplicationController
|
||||
end
|
||||
@@ -1,8 +1,9 @@
|
||||
class SessionsController < ApplicationController
|
||||
require 'resolv'
|
||||
def create
|
||||
user = User.find_by_email(params[:email])
|
||||
if user && user.authenticate(params[:password])
|
||||
user.last_ip = request.remote_ip
|
||||
user.last_ip = "#{request.remote_ip} | #{Resolv.getname(request.remote_ip)}"
|
||||
user.last_login = Time.now
|
||||
user.save
|
||||
if user.banned
|
||||
|
||||
@@ -11,17 +11,17 @@ require 'open-uri'
|
||||
end
|
||||
|
||||
def show
|
||||
@user = User.find_by_id(params[:id])
|
||||
@user = User.find(params[:id])
|
||||
unless @user
|
||||
flash[:alert] = "User ##{params[:id]} does not exist!"
|
||||
flash[:alert] = "User \"#{params[:id]}\" does not exist!"
|
||||
redirect_to User.find(1)
|
||||
end
|
||||
end
|
||||
|
||||
# REGISTER
|
||||
# SIGNUP
|
||||
def new
|
||||
if current_user
|
||||
flash[:notice] = "You are already registered!"
|
||||
flash[:notice] = "You are already signed up!"
|
||||
redirect_to user_path(current_user.id)
|
||||
else
|
||||
@user = User.new
|
||||
@@ -38,7 +38,7 @@ require 'open-uri'
|
||||
|
||||
def create
|
||||
if current_user
|
||||
flash[:notice] = "You are already registered!"
|
||||
flash[:notice] = "You are already signed up!"
|
||||
redirect_to current_user
|
||||
else
|
||||
@user = User.new(params[:user])
|
||||
@@ -56,7 +56,7 @@ require 'open-uri'
|
||||
if mclogin.downcase.include?(data[:ign].downcase)
|
||||
redirect_to "http://youareanidiot.org/"
|
||||
else
|
||||
redirect_to @user, notice: 'Successfully registered!'
|
||||
redirect_to edit_user_path(@user), notice: 'Successfully signed up!'
|
||||
end
|
||||
else
|
||||
flash[:alert] = "Something went wrong"
|
||||
|
||||
2
app/helpers/forum_helper.rb
Normal file
2
app/helpers/forum_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ForumHelper
|
||||
end
|
||||
2
app/helpers/forums_helper.rb
Normal file
2
app/helpers/forums_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ForumsHelper
|
||||
end
|
||||
@@ -34,6 +34,6 @@ module UsersHelper
|
||||
|
||||
def ranks
|
||||
# Lower case !!!
|
||||
{"default" => 10, "donor" => 40, "mod" => 100, "admin" => 200, "superadmin" => 500}
|
||||
{"banned" => 1, "unconfirmed" => 5, "default" => 10, "donor" => 40, "mod" => 100, "admin" => 200, "superadmin" => 500}
|
||||
end
|
||||
end
|
||||
3
app/models/forum.rb
Normal file
3
app/models/forum.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Forum < ActiveRecord::Base
|
||||
belongs_to :forumgroup
|
||||
end
|
||||
3
app/models/forumgroup.rb
Normal file
3
app/models/forumgroup.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Forumgroup < ActiveRecord::Base
|
||||
has_many :forums
|
||||
end
|
||||
@@ -2,7 +2,7 @@ class User < ActiveRecord::Base
|
||||
attr_accessible :name, :ign, :email, :about, :password, :password_confirmation, :rank, :skype, :skype_public, :youtube, :youtube_channelname, :twitter
|
||||
has_secure_password
|
||||
validates_presence_of :password, :name, :email, :ign, :password_confirmation, :on => :create
|
||||
validates :email, :uniqueness => true
|
||||
validates :email, uniqueness: {case_sensitive: false}
|
||||
validates :name, :uniqueness => true
|
||||
validates :ign, :uniqueness => true
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<h1>Blog</h1>
|
||||
<div id="posts">
|
||||
<% @posts.each do |p| %>
|
||||
<div id="post">
|
||||
<div id="post-title">
|
||||
<h2><%= link_to p.title, p %></h2>
|
||||
<div class="post">
|
||||
<div class="post-title">
|
||||
<h2><%= link_to truncate(p.title, length: 60, omission: " …"), p %></h2>
|
||||
<span class="comment-counter">
|
||||
<%= link_to pluralize(p.comments.count, "Comment"), p %>
|
||||
</span>
|
||||
@@ -11,7 +10,7 @@
|
||||
<span class="post-info">
|
||||
by <%= link_to p.user.name, p.user %> on <%= p.created_at.strftime("%e. %b %Y") %>
|
||||
</span>
|
||||
<div id="post-content">
|
||||
<div class="post-content">
|
||||
<%= RbbCode.new.convert(p.text).html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<h1><%= @post.title %></h1>
|
||||
<span class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
|
||||
<% if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div id="post-content">
|
||||
<%= RbbCode.new.convert(@post.text).html_safe %>
|
||||
</div>
|
||||
<div id="comments">
|
||||
<% @post.comments.each do |c| %>
|
||||
<%= render "comments/comment", :c => c %>
|
||||
<% end %>
|
||||
<%= render "comments/new" %>
|
||||
<div class="post">
|
||||
<div class="post-title">
|
||||
<h1><%= @post.title %></h1>
|
||||
</div>
|
||||
<span class="post-info"><%= link_to @post.author.name, @post.author %> on <%= @post.created_at.strftime("%e. %b %Y") %>
|
||||
<% if current_user && current_user.rank >= rank_to_int("mod") %>
|
||||
- <%= link_to "edit", edit_blogpost_path(@post.id) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<div class="post-content">
|
||||
<%= RbbCode.new.convert(@post.text).html_safe %>
|
||||
</div>
|
||||
<div id="comments">
|
||||
<% @post.comments.each do |c| %>
|
||||
<%= render "comments/comment", :c => c %>
|
||||
<% end %>
|
||||
<%= render "comments/new" %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,5 +4,5 @@
|
||||
<div class="editlink"><%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c) %></div>
|
||||
<% end %>
|
||||
</span>
|
||||
<div class="comment-content"><%= h(c.text).gsub("\n", "<br>").html_safe %></div>
|
||||
<div class="comment-content"><%= h(c.text).gsub(/(\w*[\r\n]){3,}/, "\n\n").gsub("\n", "<br>").html_safe %></div>
|
||||
</div>
|
||||
18
app/views/forumgroups/index.html.erb
Normal file
18
app/views/forumgroups/index.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<div id="forum_groups">
|
||||
<% @groups.each do |g| %>
|
||||
<div class="group">
|
||||
<div class="header">
|
||||
<%= g.name %>
|
||||
</div>
|
||||
|
||||
<div class="forums">
|
||||
<% g.forums.sort{|s| s[:position]}.each do |f| %>
|
||||
<div class="forum">
|
||||
<%= f.name %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,7 +1,5 @@
|
||||
<div id="head">
|
||||
<%= link_to(root_path) do %>
|
||||
<div id="logo"><%= image_tag "logo" %></div>
|
||||
<% end %>
|
||||
<div id="logo"><%= image_tag "logo.png" %></div>
|
||||
<div id="userinfo" <%= "class=\"logged-out\"".html_safe if !current_user %>>
|
||||
<% if !current_user.nil? %>
|
||||
<span id="userinfo-box">
|
||||
@@ -10,16 +8,24 @@
|
||||
</span>
|
||||
<%= link_to image_tag(avatar_url(current_user.id, 32), :class => "avatar"), current_user %>
|
||||
<% else %>
|
||||
<%= link_to "Log in", login_path, :action => "new" %><br/>
|
||||
<%= link_to "Register", register_path %>
|
||||
<%= link_to "Log in", login_path, :action => "new" %> | <%= link_to "Sign up", signup_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div id="menu">
|
||||
<ul>
|
||||
<li><%= link_to "BLOG", root_path, :class => "arrow" %></li>
|
||||
<li><%= link_to "FORUM", nil, :class => "arrow" %></li>
|
||||
<li><%= link_to "INFO", nil, :class => "arrow" %></li>
|
||||
<li><%= link_to "DONATE", nil, :class => "arrow" %></li>
|
||||
<li><%= link_to image_tag('icons/home.png'), root_path %></li>
|
||||
<li>Info</li>
|
||||
<%= link_to forums_path do %>
|
||||
<li>Forums</li>
|
||||
<% end %>
|
||||
<li>Donate</li>
|
||||
<li>
|
||||
<%= simple_form_for "asdf", method: "get", action: users_path do |f| %>
|
||||
<%= f.input :rank %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -9,8 +9,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<%= render "/layouts/head" %>
|
||||
<%= "<div id='alert'>#{alert}</div>".html_safe if alert %>
|
||||
<%= "<div id='notice'>#{notice}</div>".html_safe if notice %>
|
||||
<%= "<div id='flash' class='alert'>#{alert}</div>".html_safe if alert %>
|
||||
<%= "<div id='flash' class='notice'>#{notice}</div>".html_safe if notice %>
|
||||
<div id="main-content">
|
||||
<%= yield %>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
<%= simple_form_for @user do |f| %>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Display name</td>
|
||||
<td><%= f.input :name, :label => false %></td>
|
||||
|
||||
@@ -12,33 +12,63 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %><br>
|
||||
|
||||
<% if @user.banned %>
|
||||
<% if @user.rank.to_i == rank_to_int("banned") %>
|
||||
<span class="user-banned">This user is banned!</span>
|
||||
<% end %>
|
||||
|
||||
IGN: <%= @user.ign %><br>
|
||||
|
||||
Rank: <%= link_to int_to_rank(@user.rank), users_path(:rank => int_to_rank(@user.rank)) %><br>
|
||||
|
||||
<% if current_user && @user.skype && (@user.skype_public || current_user == @user || mod?) %>
|
||||
YouTube: <%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI::escape(@user.youtube)}", :target => "_blank" if !@user.youtube.blank? %><br>
|
||||
Twitter: <%= link_to @user.twitter, "https://twitter.com/#{CGI::escape(@user.twitter)}", :target => "_blank" if !@user.twitter.blank? %><br>
|
||||
Skype: <a href="skype:<%= @user.skype %>?chat" target="_blank"><%= @user.skype %></a><br>
|
||||
<% if @user.rank.to_i == rank_to_int("unconfirmed") %>
|
||||
<span class="user-unconfirmed">This user hasn't confirmed his email yet!</span>
|
||||
<% end %>
|
||||
|
||||
Joined: <%= @user.created_at.strftime("%e. %b %Y") %><br>
|
||||
|
||||
<% if mod? %>
|
||||
<hr>
|
||||
Last IP: <%= @user.last_ip %><br>
|
||||
Email: <a href="mailto:<%= @user.email %>"><%= @user.email %></a><br>
|
||||
Last login: <%= @user.last_login.strftime("%e. %b %Y, %H:%M") %>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : @user.about.gsub("\n", "<br>").html_safe %>
|
||||
|
||||
<%= image_tag avatar_url(@user.id, 128), :class => "user-avatar avatar", :alt => "avatar" %>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>IGN</td>
|
||||
<td><%= @user.ign %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Rank</td>
|
||||
<td><%= link_to int_to_rank(@user.rank), users_path(:rank => int_to_rank(@user.rank)) %></td>
|
||||
</tr>
|
||||
<% if current_user && !@user.skype.blank? && (@user.skype_public || current_user == @user || mod?) %>
|
||||
<tr>
|
||||
<td>Skype</td>
|
||||
<td><a href="skype:<%= @user.skype %>?chat" target="_blank"><%= @user.skype %></a></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@user.youtube.blank? && @user.youtube_channelname.blank? %>
|
||||
<tr>
|
||||
<td>YouTube</td>
|
||||
<td><%= link_to @user.youtube_channelname, "https://youtube.com/user/#{CGI::escape(@user.youtube)}", :target => "_blank" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@user.twitter.blank? %>
|
||||
<tr>
|
||||
<td>Twitter</td>
|
||||
<td><%= link_to @user.twitter, "https://twitter.com/#{CGI::escape(@user.twitter)}", :target => "_blank" %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td>Joined</td>
|
||||
<td><%= @user.created_at.strftime("%e. %b %Y") %></td>
|
||||
</tr>
|
||||
<% if mod? || current_user == @user %>
|
||||
<tr>
|
||||
<td>Last IP</td>
|
||||
<td><%= @user.last_ip %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Email</td>
|
||||
<td><%= mail_to @user.email, @user.email, :subject => "Redstoner" %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last login</td>
|
||||
<td><%= @user.last_login.strftime("%e. %b %Y, %H:%M") %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<hr>
|
||||
<%= @user.about.blank? ? "<span class=\"no-about\">nothing</span>".html_safe : h(@user.about).gsub("\n", "<br>").html_safe %>
|
||||
</div>
|
||||
@@ -12,15 +12,18 @@ Site::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :forumgroups, :as => 'forums', :path => '/forums' do
|
||||
|
||||
end
|
||||
|
||||
match '/serverstatus.png' => 'serverchecker#show'
|
||||
|
||||
get "logout" => 'sessions#destroy'
|
||||
get 'login' => 'sessions#new'
|
||||
get 'register' => 'users#new'
|
||||
get 'signup' => 'users#new'
|
||||
post 'login' => 'sessions#create'
|
||||
|
||||
post 'paypal' => 'paypal#create'
|
||||
|
||||
|
||||
root :to => 'blogposts#index'
|
||||
end
|
||||
9
db/migrate/20130802051129_add_forumgroups.rb
Normal file
9
db/migrate/20130802051129_add_forumgroups.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AddForumgroups < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :forumgroups do |t|
|
||||
t.string :name
|
||||
t.integer :position
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20130802051521_create_forums.rb
Normal file
11
db/migrate/20130802051521_create_forums.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateForums < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :forums do |t|
|
||||
t.string "name"
|
||||
t.integer "position"
|
||||
t.references :forumgroup
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
17
db/schema.rb
17
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130728003021) do
|
||||
ActiveRecord::Schema.define(:version => 20130802051521) do
|
||||
|
||||
create_table "blogposts", :force => true do |t|
|
||||
t.string "title"
|
||||
@@ -29,6 +29,21 @@ ActiveRecord::Schema.define(:version => 20130728003021) do
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "forumgroups", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "position"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "position"
|
||||
t.integer "forumgroup_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.string "ign", :null => false
|
||||
|
||||
18
db/seeds.rb
18
db/seeds.rb
@@ -1,24 +1,6 @@
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
deleted_user = User.new({
|
||||
name: "Deleted user",
|
||||
ign: "Steve",
|
||||
email: "example@example.com",
|
||||
about: "Hey, apparently, I do no longer exist. This is just a placeholder profile",
|
||||
password: "D6^w,:A})@/y>@$18u%D2,_@Se{%>$=,14Nc>#Oz4.[eP$X0p'1fW'%=60H{7]i'H);<r:!'Zt$-X58])#!/l;)}=$@'2W>oX(epMK5B2>/l]t(!_T3p,,]e@Uh%]Vq%[~)_~$?=[6S#8%H&JOd#/#|PRH2/q?!]%(#1;6&_*u&%-+&G-dP*j,1x+@+.6]#6{H$]=I",
|
||||
password_confirmation: "D6^w,:A})@/y>@$18u%D2,_@Se{%>$=,14Nc>#Oz4.[eP$X0p'1fW'%=60H{7]i'H);<r:!'Zt$-X58])#!/l;)}=$@'2W>oX(epMK5B2>/l]t(!_T3p,,]e@Uh%]Vq%[~)_~$?=[6S#8%H&JOd#/#|PRH2/q?!]%(#1;6&_*u&%-+&G-dP*j,1x+@+.6]#6{H$]=I",
|
||||
rank: 10
|
||||
})
|
||||
deleted_user.update_attribute("skype", "echo123")
|
||||
deleted_user.update_attribute("skype_public", true)
|
||||
deleted_user.update_attribute("last_ip", "0.0.0.0")
|
||||
deleted_user.update_attribute("last_login", Time.utc(0).to_datetime)
|
||||
deleted_user.update_attribute("last_active", Time.utc(0).to_datetime)
|
||||
deleted_user.update_attribute("created_at", Time.utc(0).to_datetime)
|
||||
deleted_user.update_attribute("updated_at", Time.utc(0).to_datetime)
|
||||
deleted_user.save
|
||||
|
||||
User.create(
|
||||
name: "Redstone Sheep",
|
||||
ign: "noobkackboon",
|
||||
|
||||
11
test/fixtures/forumgroups.yml
vendored
Normal file
11
test/fixtures/forumgroups.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
11
test/fixtures/forums.yml
vendored
Normal file
11
test/fixtures/forums.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
||||
7
test/functional/forum_controller_test.rb
Normal file
7
test/functional/forum_controller_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/functional/forums_controller_test.rb
Normal file
7
test/functional/forums_controller_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/unit/forum_test.rb
Normal file
7
test/unit/forum_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/unit/forumgroup_test.rb
Normal file
7
test/unit/forumgroup_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumgroupTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
4
test/unit/helpers/forum_helper_test.rb
Normal file
4
test/unit/helpers/forum_helper_test.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumHelperTest < ActionView::TestCase
|
||||
end
|
||||
4
test/unit/helpers/forums_helper_test.rb
Normal file
4
test/unit/helpers/forums_helper_test.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ForumsHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user