From f090feb8d4cacce9a1e8ffcda6cb542917c7e1e1 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 27 Mar 2015 13:33:34 -0400 Subject: railzZz --- app/assets/images/rails.png | Bin 0 -> 6646 bytes app/assets/javascripts/application.js | 15 ++++++++++++ app/assets/javascripts/finger.js | 2 ++ app/assets/stylesheets/application.css | 13 ++++++++++ app/assets/stylesheets/finger.css | 4 ++++ app/controllers/application_controller.rb | 3 +++ app/controllers/finger_controller.rb | 38 ++++++++++++++++++++++++++++++ app/helpers/application_helper.rb | 2 ++ app/helpers/finger_helper.rb | 2 ++ app/mailers/.gitkeep | 0 app/models/.gitkeep | 0 app/models/finger.rb | 6 +++++ app/views/finger/index.html.erb | 38 ++++++++++++++++++++++++++++++ app/views/layouts/application.html.erb | 14 +++++++++++ 14 files changed, 137 insertions(+) create mode 100644 app/assets/images/rails.png create mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/finger.js create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/assets/stylesheets/finger.css create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/finger_controller.rb create mode 100644 app/helpers/application_helper.rb create mode 100644 app/helpers/finger_helper.rb create mode 100644 app/mailers/.gitkeep create mode 100644 app/models/.gitkeep create mode 100644 app/models/finger.rb create mode 100644 app/views/finger/index.html.erb create mode 100644 app/views/layouts/application.html.erb (limited to 'app') diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 0000000..d5edc04 Binary files /dev/null and b/app/assets/images/rails.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..1145f9f --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,15 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// 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_tree . + diff --git a/app/assets/javascripts/finger.js b/app/assets/javascripts/finger.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/finger.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000..3192ec8 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + */ diff --git a/app/assets/stylesheets/finger.css b/app/assets/stylesheets/finger.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/finger.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..bf99b83 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/app/controllers/finger_controller.rb b/app/controllers/finger_controller.rb new file mode 100644 index 0000000..823e2a7 --- /dev/null +++ b/app/controllers/finger_controller.rb @@ -0,0 +1,38 @@ +class FingerController < ApplicationController + + http_basic_authenticate_with :name => "dumpfm", :password => "jazzcup", :except => :create + + def create + @finger = Finger.new() + @finger.remote_addr = request.remote_ip + @finger.nick = params[:nick] + @finger.token = params[:token] + + @lookup = Finger.where(:token => @finger.token, :nick => @finger.nick).first + + if @lookup + render :json => { 'status' => @lookup.banned ? 'KO' : 'OK' } + elsif @finger.save + render :json => { 'status' => 'OK' } + else + render :json => { 'status' => 'ERROR' } + end + end + + def index + @fingers = Finger.all + end + + def ban + @finger = Finger.find(params[:id]) + + @finger.banned = (params[:banned] == "true") + + if @finger.save + render :json => { 'status' => 'OK' } + else + render :json => { 'status' => 'ERROR' } + end + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/helpers/finger_helper.rb b/app/helpers/finger_helper.rb new file mode 100644 index 0000000..d835a6b --- /dev/null +++ b/app/helpers/finger_helper.rb @@ -0,0 +1,2 @@ +module FingerHelper +end diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/finger.rb b/app/models/finger.rb new file mode 100644 index 0000000..20a4238 --- /dev/null +++ b/app/models/finger.rb @@ -0,0 +1,6 @@ +class Finger < ActiveRecord::Base + attr_accessible :token, :nick, :remote_addr, :banned + + validates :nick, presence: true + validates :token, presence: true +end diff --git a/app/views/finger/index.html.erb b/app/views/finger/index.html.erb new file mode 100644 index 0000000..a1a2f32 --- /dev/null +++ b/app/views/finger/index.html.erb @@ -0,0 +1,38 @@ + + + + + + + + + +<% @fingers.each do |finger| %> + + + + + + + +<% end %> + +
idnickhaship
<%= finger.id %><%= finger.nick %><%= finger.token %><%= finger.remote_addr %>
+ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000..1506bc8 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Fingerprint + <%= stylesheet_link_tag "application", :media => "all" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + -- cgit v1.2.3-70-g09d2