Commit b1ff03c1 authored by Diego Pasqualin's avatar Diego Pasqualin

le-server: Completely rewritten

Signed-off-by: 's avatarDiego Pasqualin <dpasqualin@c3sl.ufpr.br>
parent d4b041f1
......@@ -4,3 +4,4 @@ le-server:
This package configure a computer as a Linux Educacional Server. It provides
tools common to servers and some unique features useful for an educational
computer laboratory.
Package: le-server
Priority: optional
Section: main
Version: 0.0.31
Version: 0.0.36
Maintainer: LE Maintainer <le-maintainer@c3sl.ufpr.br>
Description: Linux Educacional 5.0 server tools
Architecture: all
Pre-Depends: apache2, sqlite, rails, bundler
Depends: squid3, cron, openssh-server, isc-dhcp-server
Pre-Depends: apache2, sqlite, ruby1.9.1
Depends: le-pregao-232012-servidor, squid3, cron, openssh-server,
isc-dhcp-server,libsqlite3-dev, libcurl4-openssl-dev, apache2-threaded-dev, libapr1-dev, libaprutil1-dev, ruby1.9.1-dev, nodejs
#!/bin/bash
# Copyright (C) 2011-2012 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-server
#
# le-server is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#!/bin/bash
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
a2dissite 000-default
a2ensite le-server
cd /var/www/educ
update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 1000
update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.1 1000
gem install bundler --no-ri --no-rdoc
bundle install
bundle exec rake db:migrate
service apache2 restart
echo "Instalação completa...
Para acessar o portal digite o seguinte endereço no browser:
http://localhost/educ"
update-rc.d -f le-server-educ start 95 2 3 4 5 .
service le-server-educ start
exit 0
......@@ -20,4 +20,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
rm -fr /var/www/educ/ || true
rm -fr /etc/apache2/sites-enabled/le-server || true
update-rc.d -f le-server-educ remove || true
exit 0
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
<VirtualHost *:80>
ServerName educ.c3sl.ufpr.br
ServerAlias educ
DocumentRoot /home/
ProxyPass /educ http://localhost:3000/
ProxyPassReverse /educ http://localhost:3000/
<Directory ConteudoMEC/>
Order allow,deny
Allow from all
Options +Indexes
</Directory>
</VirtualHost>
#!/bin/bash
### BEGIN INIT INFO
# Provides: le-server-educ
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Inicia/Para le-server-educ web server
### END INIT INFO
PORT=3000
function kill_rails() {
pid_file="/var/www/educ/tmp/pids/server.pid"
if [ -f $pid_file ]; then
pid=$(cat $pid_file)
kill -9 $pid &>/dev/null
fi
}
case $1 in
start)
kill_rails
ruby /var/www/educ/script/rails s -e production -p $PORT & disown
;;
stop)
kill_rails
echo "Server stopped"
;;
restart)
kill_rails
ruby /var/www/educ/script/rails s -e production -p $PORT & disown
;;
esac
......@@ -7,7 +7,7 @@ gem 'rails', '3.2.13'
gem 'sqlite3'
gem 'rake'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
......@@ -21,6 +21,12 @@ group :assets do
end
gem 'jquery-rails'
gem 'passenger'
gem 'execjs'
#Paginacao
gem 'will_paginate', '3.0.3'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
......
......@@ -37,6 +37,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.6.2)
daemon_controller (1.1.4)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
......@@ -53,6 +54,10 @@ GEM
treetop (~> 1.4.8)
mime-types (1.22)
multi_json (1.7.2)
passenger (4.0.18)
daemon_controller (>= 1.1.0)
rack
rake (>= 0.8.1)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
......@@ -99,14 +104,19 @@ GEM
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
will_paginate (3.0.3)
PLATFORMS
ruby
DEPENDENCIES
coffee-rails (~> 3.2.1)
execjs
jquery-rails
passenger
rails (= 3.2.13)
rake
sass-rails (~> 3.2.3)
sqlite3
uglifier (>= 1.0.3)
will_paginate (= 3.0.3)
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
}
pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}
a {
color: #000;
&:visited {
color: #666;
}
&:hover {
}
}
div {
&.field, &.actions {
margin-bottom: 10px;
}
}
* {
margin: 0px;
padding: 0px;
font-family: arial, sans-serif;
border:0px;
}
#page_title{
margin: 10px auto;
width: 100%;
text-align: center;
}
#main_div {
width: 100%;
}
#content_div {
margin: 20px auto;
width: 800px;
}
#busca{
margin: 10px auto;
width: 50%;
}
body {
background-color: #eeeeee;
}
......@@ -25,15 +77,11 @@ body {
/*busca*/
#search_field {
top: 23px;
z-index:7;
margin-top:0px;
width:270px;
border-top: 10px;
margin: auto;
height:30px;
float:left;
left: 400px;
position: absolute;
display: block;
width: 70%;
border: none;
border-radius: 20px;
padding: 5px 8px;
......@@ -48,12 +96,10 @@ body {
input[type="submit"] {
z-index:7;
margin: auto;
width: 25%;
background-color: #87af26;
font-family: arial;
float: left;
position: absolute;
left: 690px;
top: 23px;
border-radius: 24px;
border: solid 1px gainsboro;
padding: 12px;
......@@ -96,7 +142,7 @@ h1 {
background: #D0F79C;
box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
margin-right: 20px;
margin-top:20px;
margin-bottom:20px;
transition: all 300ms linear;
-webkit-transition: all 0.8s ease 0s;
-moz-transition: all 0.8s ease 0s;
......@@ -121,6 +167,7 @@ h1 {
top: 0px;
text-align: center;
transition: all 200ms linear;
float: left;
}
.ca-icon img{
......@@ -180,16 +227,47 @@ h1 {
animation: moveFromBottom 500ms ease;
}
.voltar_anchor{
position: absolute;
top: 65px;
float: left;
margin-left: 5px;
p{
font-size: 20px;
font-weight: bold;
color: #87af26;
}
}
.img_pg {
position: absolute;
top: 4px;
width: 60px;
height: 60px;
top: 30px;
width: 80px;
height: 80px;
float: left;
margin-right: 15px;
margin-left: 85px;
}
/*Estilo das demais páginas*/
#content2{
.page_btn{
a, span{
color: #87af26;
}
em, span.disabled{
color: #376000;
}
}
.page_size_p{
float:right;
color: #87af26;
margin-right: 6px;
}
.page_size_select{
float: right;
}
}
#topo_pg {
position: absolute;
left: 80px;
......@@ -216,6 +294,7 @@ h1 {
.table_pg {
margin:0px;padding:0px;
margin-top:6px;
width:100%;
box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
border:1px solid #ffffff;
......@@ -242,7 +321,7 @@ h1 {
vertical-align:middle;
border:1px solid #ffffff;
border-width:0px 1px 1px 0px;
text-align:left;
text-align:center;
padding:14px;
font-size:12px;
font-family:Arial;
......
......@@ -11,7 +11,10 @@ class ConteudosController < ApplicationController
end
def dompub
@conteudos = Conteudo.find_all_by_category("dp")
@category = "dp"
@page_size = [25,50,100]
@per_page = params[:per_page] || @page_size[0]
@conteudos = Conteudo.page_category(@category,params[:page],@per_page)
respond_to do |format|
format.html # contedu.html.erb
......@@ -20,8 +23,10 @@ class ConteudosController < ApplicationController
end
def prof
@conteudos = Conteudo.find_all_by_category("portaldoprofessor")
@category = "portaldoprofessor"
@page_size = [25,50,100]
@per_page = params[:per_page] || @page_size[0]
@conteudos = Conteudo.page_category(@category,params[:page],@per_page)
respond_to do |format|
format.html # prof.html.erb
format.json { render json: @conteudos }
......@@ -29,7 +34,10 @@ class ConteudosController < ApplicationController
end
def tvesc
@conteudos = Conteudo.find_all_by_category("tvescola")
@category = "tvescola"
@page_size = [25,50,100]
@per_page = params[:per_page] || @page_size[0]
@conteudos = Conteudo.page_category(@category,params[:page],@per_page)
respond_to do |format|
format.html # tvesc.html.erb
......@@ -38,81 +46,13 @@ class ConteudosController < ApplicationController
end
def search
@conteudos = Conteudo.search params[:search]
@search = params[:search] || params[:search_safe] || ''
@page_size = [25,50,100]
@per_page = params[:per_page] || @page_size[0]
@conteudos = Conteudo.search(@search,params[:page],@per_page)
respond_to do |format|
format.html # search.html.erb
format.json { render json: @conteudos }
end
end
# GET /conteudos/1
# GET /conteudos/1.json
def show
@conteudo = Conteudo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @conteudo }
end
end
# GET /conteudos/new
# GET /conteudos/new.json
def new
@conteudo = Conteudo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @conteudo }
end
end
# GET /conteudos/1/edit
def edit
@conteudo = Conteudo.find(params[:id])
end
# POST /conteudos
# POST /conteudos.json
def create
@conteudo = Conteudo.new(params[:conteudo])
respond_to do |format|
if @conteudo.save
format.html { redirect_to @conteudo, notice: 'Conteudo was successfully created.' }
format.json { render json: @conteudo, status: :created, location: @conteudo }
else
format.html { render action: "new" }
format.json { render json: @conteudo.errors, status: :unprocessable_entity }
end
end
end
# PUT /conteudos/1
# PUT /conteudos/1.json
def update
@conteudo = Conteudo.find(params[:id])
respond_to do |format|
if @conteudo.update_attributes(params[:conteudo])
format.html { redirect_to @conteudo, notice: 'Conteudo was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @conteudo.errors, status: :unprocessable_entity }
end
end
end
# DELETE /conteudos/1
# DELETE /conteudos/1.json
def destroy
@conteudo = Conteudo.find(params[:id])
@conteudo.destroy
respond_to do |format|
format.html { redirect_to conteudos_url }
format.json { head :no_content }
end
end
end
module ApplicationHelper
def relative_path(path)
"/educ" + path
end
end
class Conteudo < ActiveRecord::Base
attr_accessible :author, :category, :href, :media, :sub_category, :title
def self.search(search)
def self.search(search, page,per_page)
search_condition = "%" + search + "%"
find(:all, :conditions => ['title LIKE ? OR author LIKE ? OR sub_category LIKE ?', search_condition, search_condition, search_condition])
paginate per_page: per_page, page: page,
conditions: ['title like ? or author like ? or sub_category like ?', search_condition, search_condition, search_condition],
order: 'title'
end
def self.page_category(category,page,per_page)
paginate per_page: per_page, page: page,
conditions: ['category = ?',category],
order: 'title'
end
def self.paginated?(category,min_page)
if Conteudo.find_all_by_category(category).count > min_page
true
else
false
end
end
def self.paginated_search?(search,min_page)
search_condition = "%" + search + "%"
if Conteudo.find(:all, :conditions => ['title LIKE ? OR author LIKE ? OR sub_category LIKE ?', search_condition, search_condition, search_condition]).count > min_page
true
else
false
end
end
end
<div id="wrapper">
<% @page_title = "Domínio Público" %>
<div id="content2">
<p><a href="/conteudos/" style="top: 90px; color: #87af26; font-size: 21px; font-weight: bold; position: absolute;">Voltar para a página inicial</a></p>
<%= link_to(relative_path(conteudos_path), class: "voltar_anchor") do %>
<p> Voltar </p>
<% end %>
<div id="divclear" ></div>
<div id="header_pg">
<img src="/images/dominio.png" alt="" class="img_pg"><h1 id="topo_pg">Domínio Público</h1></div>
<%= image_tag("dominio.png", class: "img_pg") %>
<div id="divclear" ></div>
<% if Conteudo.paginated?(@category,@page_size[0]) %>
<%= select_tag :per_page, options_for_select(@page_size, params[:per_page].to_i),
:onchange => "if(this.value){window.location='?per_page='+this.value;}", class: 'page_size_select' %>
<p class="page_size_p">Tamanho da pagina:</p>
<% end %>
<%= will_paginate @conteudos, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
<div class="table_pg" >
<table >
<tr>
......@@ -16,7 +25,7 @@
<% @conteudos.each do |contedu| %>
<% if File.exist?(contedu.href) -%>
<tr>
<td><a href="<%= contedu.href %>"><%= contedu.title %></a></td>
<td><a href="<%= path_to_file(contedu.href) %>"><%= contedu.title %></a></td>
<td><%= contedu.author %></td>
<td><%= contedu.sub_category %></td>
<td><%= contedu.media %></td>
......@@ -25,6 +34,7 @@
<% end %>
</table>
</div>
<%= will_paginate @conteudos, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
</div>
</div>
</div>
......
<div id="content-index">
<h1 style="position: absolute; left: 18px; top: 34px;">Conteúdo Educacional</h1>
<% @page_title = "Conteúdo Educacional" %>
<ul class="ca-menu" style="width: 350px; margin: 0px auto; position: relative; float: left; padding: 16px;">
<li>
<a href="/conteudos/dompub">
<span class="ca-icon"><img src="/images/dominio.png" alt="" ></span>
<%= link_to(relative_path(dompub_conteudos_path)) do %>
<span class="ca-icon"><%= image_tag("dominio.png") %></span>
<div class="ca-content">
<h2 class="ca-main">Domínio Público</h2>
</div>
</a>
<% end %>
</li>
<li>
<a href="/conteudos/prof.html">
<span class="ca-icon"><img src="/images/portal_prof.png" alt="" ></span>
<%= link_to(relative_path(prof_conteudos_path)) do %>
<span class="ca-icon"><%= image_tag("portal_prof.png") %></span>
<div class="ca-content">
<h2 class="ca-main">Portal do Professor</h2>
</div>
</a>
<% end %>
</li>
</ul>
<ul class="ca-menu" style="width: 350px; margin: 0px auto; position: relative; float: left; padding: 16px;">
<li>
<a href="/conteudos/tvesc">
<span class="ca-icon"><img src="/images/tv_escola.png" alt="" ></span>
<%= link_to(relative_path(tvesc_conteudos_path)) do %>
<span class="ca-icon"><%= image_tag("tv_escola.png") %></span>
<div class="ca-content">
<h2 class="ca-main">TV Escola</h2>
</div>
</a>
</li>
<li>
<a href="/home/dominio_publico">
<span class="ca-icon"><img src="/images/cont_dinamico.png" alt="" ></span>
<div class="ca-content">
<h2 class="ca-main">Conteúdo Dinâmico</h2>
</div>
</a>
<% end %>
</li>
<% if File.directory?('/home/ConteudoMEC/') %>
<li>
<a href="/ConteudoMEC">
<span class="ca-icon"><%= image_tag("cont_dinamico.png") %></span>
<div class="ca-content">
<h2 class="ca-main">Conteúdo Dinâmico</h2>
</div>
</a>
</li>
<% end %>
</ul>
</div>
<div id="wrapper">
<% @page_title = "Portal do Professor" %>
<div id="content2">
<p><a href="/conteudos/" style="top: 90px; color: #87af26; font-size: 21px; font-weight: bold; position: absolute;">Voltar para a página inicial</a></p>
<%= link_to(relative_path(conteudos_path), class: "voltar_anchor") do %>
<p> Voltar </p>
<% end %>
<div id="divclear" ></div>
<div id="header_pg">
<img src="/images/portal_prof.png" alt="" class="img_pg"><h1 id="topo_pg">Portal do Professor</h1></div>
<%= image_tag("portal_prof.png", class: "img_pg") %> <br>
<div id="divclear" ></div>
<% if Conteudo.paginated?(@category,@page_size[0]) %>
<%= select_tag :per_page, options_for_select(@page_size, params[:per_page].to_i),
:onchange => "if(this.value){window.location='?per_page='+this.value;}" , class: 'page_size_select'%>
<p class="page_size_p">Tamanho da pagina:</p>
<% end %>
<%= will_paginate @conteudos, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
<div class="table_pg" >
<table >
<tr>
......@@ -25,6 +34,7 @@
<% end %>
</table>
</div>
<%= will_paginate @conteudos, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
</div>
</div>
</div>
......
<div id="wrapper">
<% @page_title = "Contúdo Educacional" %>
<div id="content2">
<p><a href="/conteudos/" style="top: 90px; color: #87af26; font-size: 21px; font-weight: bold; position: absolute;">Voltar para a página inicial</a></p>
<div id="divclear" ></div>
<div id="header_pg">
<h1 id="topo_pg" style="left: 15px;">Conteúdo Educacional</h1></div>
<%= link_to(relative_path(conteudos_path), class: "voltar_anchor") do %>
<p> Voltar </p>
<% end %>
<div id="divclear" ></div>
<% if Conteudo.paginated_search?(@search,@page_size[0]) %>
<%= select_tag :per_page, options_for_select(@page_size, params[:per_page].to_i),
:onchange => "if(this.value){window.location='?per_page='+this.value+'&search=#{@search.gsub(' ','+')}';}" , class: 'page_size_select'%>
<p class="page_size_p">Tamanho da pagina:</p>
<% end %>
<%= will_paginate @conteudos,params: {search: @search}, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
<div class="table_pg" >
<table >
<tr>
......@@ -25,7 +31,7 @@
<% end %>
</table>
</div>
</div>
<%= will_paginate @conteudos, class: 'page_btn', previous_label: '« Anterior', next_label: 'Próxima »'%>
</div>
</div>