-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robin
committed
Jan 30, 2010
0 parents
commit 9f45bdc
Showing
114 changed files
with
12,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
== heartbeat daemon | ||
|
||
receive heartbeats from nodes running pirate freifunk | ||
|
||
heartbeat daemon is able to receive the following data in three different management modes: | ||
|
||
= mode: update | ||
node_id:string | ||
rev:string | ||
|
||
= mode: information | ||
see update, additionally | ||
name:string | ||
lat:decimal | ||
lon:decimal | ||
crew:string | ||
lv:string | ||
partei:integer //should be 1, if pirate party node | ||
|
||
= mode: highscore | ||
see information, additionally | ||
neighboors:integer | ||
clients:integer | ||
|
||
|
||
the path | ||
|
||
http://<server>:<port>/nodes/status/update?<var1>=<value1>&<var2>=<value2>&...&<varn>=<valuen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require(File.join(File.dirname(__FILE__), 'config', 'boot')) | ||
|
||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
require 'tasks/rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Filters added to this controller apply to all controllers in the application. | ||
# Likewise, all the methods added will be available for all controllers. | ||
|
||
class ApplicationController < ActionController::Base | ||
helper :all # include all helpers, all the time | ||
|
||
# See ActionController::RequestForgeryProtection for details | ||
# Uncomment the :secret if you're not using the cookie session store | ||
protect_from_forgery # :secret => '61ef15b8d388689d38e67fbd733cdf66' | ||
|
||
# See ActionController::Base for details | ||
# Uncomment this to filter the contents of submitted sensitive data parameters | ||
# from your application log (in this case, all fields with names like "password"). | ||
# filter_parameter_logging :password | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
class CrewsController < ApplicationController | ||
# GET /crews | ||
# GET /crews.xml | ||
def index | ||
@crews = Crew.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @crews } | ||
end | ||
end | ||
|
||
# GET /crews/1 | ||
# GET /crews/1.xml | ||
def show | ||
@crew = Crew.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @crew } | ||
end | ||
end | ||
|
||
# GET /crews/new | ||
# GET /crews/new.xml | ||
def new | ||
@crew = Crew.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @crew } | ||
end | ||
end | ||
|
||
# GET /crews/1/edit | ||
def edit | ||
@crew = Crew.find(params[:id]) | ||
end | ||
|
||
# POST /crews | ||
# POST /crews.xml | ||
def create | ||
@crew = Crew.new(params[:crew]) | ||
|
||
respond_to do |format| | ||
if @crew.save | ||
flash[:notice] = 'Crew was successfully created.' | ||
format.html { redirect_to(@crew) } | ||
format.xml { render :xml => @crew, :status => :created, :location => @crew } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @crew.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /crews/1 | ||
# PUT /crews/1.xml | ||
def update | ||
@crew = Crew.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @crew.update_attributes(params[:crew]) | ||
flash[:notice] = 'Crew was successfully updated.' | ||
format.html { redirect_to(@crew) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @crew.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /crews/1 | ||
# DELETE /crews/1.xml | ||
def destroy | ||
@crew = Crew.find(params[:id]) | ||
@crew.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(crews_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
class LandesverbandsController < ApplicationController | ||
# GET /landesverbands | ||
# GET /landesverbands.xml | ||
def index | ||
@landesverbands = Landesverband.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @landesverbands } | ||
end | ||
end | ||
|
||
# GET /landesverbands/1 | ||
# GET /landesverbands/1.xml | ||
def show | ||
@landesverband = Landesverband.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @landesverband } | ||
end | ||
end | ||
|
||
# GET /landesverbands/new | ||
# GET /landesverbands/new.xml | ||
def new | ||
@landesverband = Landesverband.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @landesverband } | ||
end | ||
end | ||
|
||
# GET /landesverbands/1/edit | ||
def edit | ||
@landesverband = Landesverband.find(params[:id]) | ||
end | ||
|
||
# POST /landesverbands | ||
# POST /landesverbands.xml | ||
def create | ||
@landesverband = Landesverband.new(params[:landesverband]) | ||
|
||
respond_to do |format| | ||
if @landesverband.save | ||
flash[:notice] = 'Landesverband was successfully created.' | ||
format.html { redirect_to(@landesverband) } | ||
format.xml { render :xml => @landesverband, :status => :created, :location => @landesverband } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @landesverband.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /landesverbands/1 | ||
# PUT /landesverbands/1.xml | ||
def update | ||
@landesverband = Landesverband.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @landesverband.update_attributes(params[:landesverband]) | ||
flash[:notice] = 'Landesverband was successfully updated.' | ||
format.html { redirect_to(@landesverband) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @landesverband.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /landesverbands/1 | ||
# DELETE /landesverbands/1.xml | ||
def destroy | ||
@landesverband = Landesverband.find(params[:id]) | ||
@landesverband.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(landesverbands_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
class NodesController < ApplicationController | ||
# GET /nodes | ||
# GET /nodes.xml | ||
def index | ||
@nodes = Node.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @nodes } | ||
end | ||
end | ||
|
||
# GET /nodes/1 | ||
# GET /nodes/1.xml | ||
def show | ||
@node = Node.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @node } | ||
end | ||
end | ||
|
||
#function triggered by heartbeat script (node side) | ||
def status | ||
if !params[:node_id] && !params[:rev] | ||
return | ||
end | ||
|
||
#check for node | ||
@node = Node.find(:first, :conditions => ['node_id = ?', params[:node_id]]) | ||
|
||
if !@node | ||
#new node creation | ||
@node = Node.new | ||
|
||
#params saved for update | ||
@node.node_id = params[:node_id] | ||
@node.rev = params[:rev] | ||
|
||
#params saved for informations | ||
if params[:name] && params[:lat] && params[:lon] && params[:crew] && params[:lv] && params[:partei] | ||
@node.name = params[:name] | ||
@node.lat = params[:lat] | ||
@node.lon = params[:lon] | ||
|
||
#create crew, if necessary | ||
if !(crew = Crew.find(:first, :conditions => ['name = ?', params[:crew].capitalize])) | ||
crew = Crew.new | ||
crew.name = params[:crew].capitalize | ||
crew.save | ||
end | ||
@node.crew_id = crew.id | ||
|
||
#create lv, if necessary | ||
if !(lv = Landesverband.find(:first, :conditions => ['name = ?', params[:lv].capitalize])) | ||
lv = Landesverband.new | ||
lv.name = params[:lv].capitalize | ||
lv.save | ||
end | ||
@node.landesverband_id = lv.id | ||
@node.partei_id = Partei.find(:first, :conditions => ['id = ?', params[:partei]]) | ||
|
||
#params saved for highscore | ||
if params[:neighboors] && params[:clients] | ||
@node.neighboors_count = params[:neighboors] | ||
@node.clients_count = params[:clients] | ||
end | ||
end | ||
|
||
#save node entry | ||
@node.save | ||
else | ||
#update node | ||
|
||
#params saved for update | ||
if params[:rev] | ||
@node.rev = params[:rev] | ||
|
||
#params saved for informations | ||
if params[:name] && params[:lat] && params[:lon] && params[:crew] && params[:lv] && params[:partei] | ||
@node.name = params[:name] | ||
@node.lat = params[:lat] | ||
@node.lon = params[:lon] | ||
#create crew, if necessary | ||
if !(crew = Crew.find(:first, :conditions => ['name = ?', params[:crew].capitalize])) | ||
crew = Crew.new | ||
crew.name = params[:crew].capitalize | ||
crew.save | ||
end | ||
@node.crew_id = crew.id | ||
|
||
#create lv, if necessary | ||
if !(lv = Landesverband.find(:first, :conditions => ['name = ?', params[:lv].capitalize])) | ||
lv = Landesverband.new | ||
lv.name = params[:lv].capitalize | ||
lv.save | ||
end | ||
@node.landesverband_id = lv.id | ||
@node.partei_id = Partei.find(:first, :conditions => ['id = ?', params[:partei]]) | ||
|
||
|
||
#params saved for highscore | ||
if params[:neighboors] && params[:clients] | ||
@node.neighboors_count = @node.neighboors_count < params[:neighboors] ? params[:neighboors] : @node.neighboors_count | ||
@node.clients_count = @node.clients_count < params[:clients] ? params[:clients] : @node.clients_count | ||
end | ||
end | ||
end | ||
end | ||
respond_to do |format| | ||
if @node.save | ||
flash[:notice] = 'Node was successfully created.' | ||
format.html { redirect_to :action => "index" } | ||
format.xml { render :xml => @node, :status => :created, :location => @node } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @node.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
|
||
# DELETE /nodes/1 | ||
# DELETE /nodes/1.xml | ||
def destroy | ||
@node = Node.find(params[:id]) | ||
@node.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(nodes_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
Oops, something went wrong.