Nicolae Claudius
13 years ago
47 changed files with 1185 additions and 66 deletions
After Width: | Height: | Size: 226 B |
@ -0,0 +1,36 @@
|
||||
@import "compass/css3/gradient"; |
||||
@import "compass/css3/border-radius"; |
||||
@import "compass/css3/box-shadow"; |
||||
|
||||
@mixin cupid-green { |
||||
@include background( |
||||
image-url("marketing/action/slick-black.png"), |
||||
linear-gradient(top, #7fbf4d, #63a62f) |
||||
); |
||||
border: 1px solid #63a62f; |
||||
border-bottom: 1px solid #5b992b; |
||||
@include border-radius(3px); |
||||
@include box-shadow(inset 0 1px 0 0 #96ca6d); |
||||
color: #fff; |
||||
font: bold 11px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; |
||||
line-height: 1; |
||||
padding: 7px 0 8px 0; |
||||
text-align: center; |
||||
text-shadow: 0 -1px 0 #4c9021; |
||||
width: 150px; |
||||
|
||||
&:hover { |
||||
@include background( |
||||
image-url("marketing/action/slick-black.png"), |
||||
linear-gradient(top, #76b347, #5e9e2e) |
||||
); |
||||
@include box-shadow(inset 0 1px 0 0 #8dbf67); |
||||
cursor: pointer; |
||||
} |
||||
|
||||
&:active { |
||||
border: 1px solid #5b992b; |
||||
border-bottom: 1px solid #538c27; |
||||
@include box-shadow(inset 0 0 8px 4px #548c29, 0 1px 0 0 #eee); |
||||
} |
||||
} |
@ -1,22 +1,38 @@
|
||||
class DomainsController < ApplicationController |
||||
|
||||
begin |
||||
active_scaffold :domain do |conf| |
||||
conf.columns = [:name, :records] |
||||
conf.create.columns = [:name] |
||||
conf.update.columns = [:name] |
||||
conf.columns = [:name, :soa_record, :ns_records, :records] |
||||
conf.list.columns = [:name, :soa_record, :ns_records, :records] |
||||
conf.create.columns = [:name, :soa_record, :ns_records] |
||||
conf.update.columns = [:name, :soa_record, :ns_records] |
||||
conf.actions.exclude :show |
||||
conf.list.sorting = { :name => :asc } |
||||
end |
||||
rescue => e |
||||
puts e.backtrace |
||||
raise e |
||||
|
||||
conf.columns[:records].label = 'All Records' |
||||
end |
||||
|
||||
protected |
||||
|
||||
|
||||
def before_create_save(record) |
||||
record.type = 'NATIVE' |
||||
end |
||||
|
||||
# TODO: move to core |
||||
def do_edit_associated |
||||
@parent_record = params[:id].nil? ? new_model : find_if_allowed(params[:id], :update) |
||||
@column = active_scaffold_config.columns[params[:association]] |
||||
|
||||
# NOTE: we don't check whether the user is allowed to update this record, because if not, we'll still let them associate the record. we'll just refuse to do more than associate, is all. |
||||
@record = @column.association.klass.find(params[:associated_id]) if params[:associated_id] |
||||
@record ||= @column.singular_association? ? @parent_record.send(:"build_#{@column.name}") : @parent_record.send(@column.name).build |
||||
reflection = @parent_record.class.reflect_on_association(@column.name) |
||||
if reflection && reflection.reverse |
||||
reverse_macro = @record.class.reflect_on_association(reflection.reverse).macro |
||||
@record.send(:"#{reflection.reverse}=", @parent_record) if [:has_one, :belongs_to].include?(reverse_macro) |
||||
end |
||||
|
||||
@scope = "[#{@column.name}]" |
||||
@scope += (@record.new_record?) ? "[#{(Time.now.to_f*1000).to_i.to_s}]" : "[#{@record.id}]" if @column.plural_association? |
||||
end |
||||
|
||||
end |
||||
|
@ -0,0 +1,12 @@
|
||||
class NsController < ApplicationController |
||||
active_scaffold :ns do |conf| |
||||
conf.columns = [:name, :content, :ttl] |
||||
conf.columns[:content].label = 'Hostname' |
||||
end |
||||
|
||||
protected |
||||
|
||||
def beginning_of_chain |
||||
super.readonly(false) |
||||
end |
||||
end |
@ -1,5 +1,12 @@
|
||||
class RecordsController < ApplicationController |
||||
active_scaffold :record do |conf| |
||||
conf.sti_children = [:SOA, :NS] |
||||
conf.columns = [:name, :type, :content, :ttl, :prio, :change_date] |
||||
end |
||||
|
||||
protected |
||||
|
||||
def beginning_of_chain |
||||
super.readonly(false) |
||||
end |
||||
end |
||||
|
@ -0,0 +1,11 @@
|
||||
class SoasController < ApplicationController |
||||
active_scaffold :soa do |conf| |
||||
conf.columns = [:name, :primary_ns, :contact, :ttl] |
||||
end |
||||
|
||||
protected |
||||
|
||||
def beginning_of_chain |
||||
super.readonly(false) |
||||
end |
||||
end |
@ -0,0 +1,17 @@
|
||||
# See #A |
||||
|
||||
# = IPv4 Address Record (A) |
||||
# |
||||
# Defined in RFC 1035. Forward maps a host name to IPv4 address. The only |
||||
# parameter is an IP address in dotted decimal format. The IP address in not |
||||
# terminated with a '.' (dot). Valid host name format (a.k.a 'label' in DNS |
||||
# jargon). If host name is BLANK (or space) then the last valid name (or label) |
||||
# is substituted. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/a.html |
||||
# |
||||
class A < Record |
||||
# Only accept valid IPv4 addresses |
||||
validates :content, :presence => true, :ip => true |
||||
|
||||
end |
@ -0,0 +1,13 @@
|
||||
# See #CNAME |
||||
|
||||
# = Canonical Name Record (CNAME) |
||||
# |
||||
# A CNAME record maps an alias or nickname to the real or Canonical name which |
||||
# may lie outside the current zone. Canonical means expected or real name. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/cname.html |
||||
# |
||||
class CNAME < Record |
||||
validates :content, :presence => true, :hostname => true |
||||
|
||||
end |
@ -1,4 +1,33 @@
|
||||
class Domain < ActiveRecord::Base |
||||
set_inheritance_column { 'sti_type' } |
||||
has_many :records, :dependent => :destroy # :delete_all ? |
||||
set_inheritance_column "sti_disabled" |
||||
nilify_blanks |
||||
|
||||
belongs_to :user |
||||
has_many :records, :dependent => :destroy |
||||
|
||||
cattr_reader :types |
||||
@@types = ['NATIVE', 'MASTER', 'SLAVE', 'SUPERSLAVE'] |
||||
|
||||
has_one :soa_record, :class_name => 'SOA', :conditions => {:type => 'SOA'} |
||||
|
||||
# Handle relations and validations for all resource records on this zone |
||||
validates_associated :records |
||||
for type in Record.types |
||||
has_many :"#{type.downcase}_records", :class_name => type, :conditions => {:type => type} |
||||
validates_associated :"#{type.downcase}_records" |
||||
end |
||||
|
||||
validates :name, :presence => true, :uniqueness => true, :domainname => {:require_valid_tld => false} |
||||
validates :master, :presence => true, :if => :slave? |
||||
validates :master, :ip => true, :if => :slave?, :allow_nil => true |
||||
validates :type, :inclusion => { :in => @@types, :message => "Unknown domain type" } |
||||
validates :soa_record, :presence => {:unless => :slave?} |
||||
validates_associated :soa_record, :allow_nil => true |
||||
validates :ns_records, :presence => true, :length => {:minimum => 2, :message => "must have be at least 2"} |
||||
MASTER_FORMAT = /\A(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\z/ |
||||
validate :master, :presence => {:if => :slave?}, |
||||
:format => {:with => MASTER_FORMAT, :allow_blank => true, :if => :slave?} |
||||
|
||||
# Are we a slave domain |
||||
def slave?; self.type == 'SLAVE' end |
||||
end |
||||
|
@ -0,0 +1,15 @@
|
||||
# See #MX |
||||
|
||||
# = Mail Exchange Record (MX) |
||||
# Defined in RFC 1035. Specifies the name and relative preference of mail |
||||
# servers (mail exchangers in the DNS jargon) for the zone. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/mx.html |
||||
# |
||||
class MX < Record |
||||
validates :prio, |
||||
:numericality => {:greater_than_or_equal_to => 0, :less_than_or_equal_to => 65535, :only_integer => true} |
||||
validates :content, :presence => true, :hostname => true |
||||
|
||||
def supports_prio?; true end |
||||
end |
@ -0,0 +1,27 @@
|
||||
# See #NS |
||||
|
||||
# = Name Server Record (NS) |
||||
# |
||||
# Defined in RFC 1035. NS RRs appear in two places. Within the zone file, in |
||||
# which case they are authoritative records for the zone's name servers. At the |
||||
# point of delegation for either a subdomain of the zone or in the zone's |
||||
# parent. Thus the zone example.com's parent zone (.com) will contain |
||||
# non-authoritative NS RRs for the zone example.com at its point of delegation |
||||
# and subdomain.example.com will have non-authoritative NS RSS in the zone |
||||
# example.com at its point of delegation. NS RRs at the point of delegation are |
||||
# never authoritative only NS RRs for the zone are regarded as authoritative. |
||||
# While this may look a fairly trivial point, is has important implications for |
||||
# DNSSEC. |
||||
# |
||||
# NS RRs are required because DNS queries respond with an authority section |
||||
# listing all the authoritative name servers, for sub-domains or queries to the |
||||
# zones parent where they are required to allow referral to take place. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/ns.html |
||||
# |
||||
class NS < Record |
||||
validates :content, :presence => true, :hostname => true |
||||
|
||||
end |
||||
|
||||
Ns = NS |
@ -1,4 +1,41 @@
|
||||
class Record < ActiveRecord::Base |
||||
set_inheritance_column { 'sti_type' } |
||||
belongs_to :domain |
||||
|
||||
cattr_reader :types |
||||
@@types = ['SOA', 'NS', 'A', 'MX', 'TXT', 'CNAME'] |
||||
|
||||
validates :domain_id, :name, :presence => true |
||||
validates :type, :inclusion => {:in => @@types, :message => "Unknown record type"} |
||||
# RFC 2181, 8 |
||||
validates :ttl, :numericality => { :greater_than_or_equal_to => 0, :less_than => 2**31 }, :allow_blank => true |
||||
|
||||
before_validation :prepare_name! |
||||
before_save :update_change_date |
||||
after_save :update_soa_serial |
||||
|
||||
# By default records don't support priorities. |
||||
# Those who do can overwrite this in their own classes. |
||||
def supports_priority?; false end |
||||
|
||||
def shortname; name.gsub(/\.?#{self.domain.name}$/, '') end |
||||
def shortname=(value); self.name = value end |
||||
|
||||
protected |
||||
|
||||
def prepare_name! |
||||
return if domain.nil? or domain.name.blank? |
||||
self.name = domain.name if name.blank? or name == '@' |
||||
self.name << ".#{domain.name}" unless name.index(domain.name) |
||||
end |
||||
|
||||
# Update the change date for automatic serial number generation |
||||
def update_change_date; self.change_date = Time.now.to_i end |
||||
|
||||
def update_soa_serial #:nodoc: |
||||
unless type == 'SOA' || @serial_updated || domain.slave? |
||||
domain.soa_record.update_serial! |
||||
@serial_updated = true |
||||
end |
||||
end |
||||
|
||||
end |
||||
|
@ -0,0 +1,72 @@
|
||||
# See #SOA |
||||
|
||||
# = Start of Authority Record |
||||
# Defined in RFC 1035. The SOA defines global parameters for the zone (domain). |
||||
# There is only one SOA record allowed in a zone file. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/soa.html |
||||
# |
||||
class SOA < Record |
||||
validates :domain_id, :uniqueness => true # one SOA per domain |
||||
validates :name, :presence => true, :hostname => true |
||||
validates :content, :presence => true |
||||
validates :primary_ns, :presence => true |
||||
CONTACT_FORMAT = /\A[a-zA-Z0-9\-\.]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,6}\z/ |
||||
validates :contact, :format => {:with => CONTACT_FORMAT} |
||||
validates :serial, :presence => true, :numericality => {:allow_blank => true, :greater_than_or_equal_to => 0} |
||||
|
||||
before_validation :assemble_content |
||||
before_update :update_serial |
||||
after_initialize :disassemble_content |
||||
|
||||
# This allows us to have these convenience attributes act like any other |
||||
# column in terms of validations |
||||
attr_accessor :primary_ns, :contact, :serial |
||||
|
||||
# Treat contact specially |
||||
# replacing the first period with an @ if no @'s are present |
||||
def contact=(email) |
||||
email.sub!('.', '@') if email.present? && email.index('@').nil? |
||||
@contact = email |
||||
end |
||||
|
||||
# Hook into #reload |
||||
def reload_with_content |
||||
reload_without_content |
||||
disassemble_content |
||||
end |
||||
alias_method_chain :reload, :content |
||||
|
||||
# Updates the serial number to the next logical one. Format of the generated |
||||
# serial is YYYYMMDDNN, where NN is the number of the change for the day. |
||||
# 01 for the first change, 02 the seconds, etc... |
||||
# |
||||
# If the serial number is 0, we opt for PowerDNS's automatic serial number |
||||
# generation, that gets triggered by updating the change_date |
||||
def update_serial |
||||
return if self.content_changed? |
||||
date_serial = Time.now.strftime( "%Y%m%d00" ).to_i |
||||
@serial = (@serial.nil? || date_serial > @serial) ? date_serial : @serial + 1 |
||||
end |
||||
|
||||
# Same as #update_serial and saves the record |
||||
def update_serial! |
||||
update_serial |
||||
save |
||||
end |
||||
|
||||
private |
||||
|
||||
def assemble_content |
||||
self.content = "#{@primary_ns} #{@contact} #{@serial}".strip |
||||
end |
||||
|
||||
# Update our convenience accessors when the object has changed |
||||
def disassemble_content |
||||
@primary_ns, @contact, @serial = content.split(/\s+/) unless content.blank? |
||||
@serial = @serial.to_i unless @serial.nil? |
||||
update_serial if @serial.nil? || @serial.zero? |
||||
end |
||||
end |
||||
|
||||
Soa = SOA |
@ -0,0 +1,14 @@
|
||||
# See #TXT |
||||
|
||||
# = Text Record (TXT) |
||||
# Provides the ability to associate some text with a host or other name. The TXT |
||||
# record is used to define the Sender Policy Framework (SPF) information record |
||||
# which may be used to validate legitimate email sources from a domain. The SPF |
||||
# record while being increasing deployed is not (July 2004) a formal IETF RFC |
||||
# standard. |
||||
# |
||||
# Obtained from http://www.zytrax.com/books/dns/ch8/txt.html |
||||
class TXT < Record |
||||
validate :content, :presence => true |
||||
|
||||
end |
@ -0,0 +1,62 @@
|
||||
# Validates IP addresses |
||||
# |
||||
# @author Kim Nørgaard <jasen@jasen.dk> |
||||
class IpValidator < ActiveModel::EachValidator |
||||
|
||||
# @param [Hash] options Options for validation |
||||
# @option options [Symbol] :ip_type (:any) The IP address type (:any, :v4 or :v6) |
||||
# @see ActiveModel::EachValidator#new |
||||
def initialize(options) |
||||
options[:ip_type] ||= :any |
||||
super |
||||
end |
||||
|
||||
def validate_each(record, attribute, value) |
||||
case options[:ip_type] |
||||
when :v4 |
||||
record.errors.add(attribute, options[:message] || :ipv4) unless ipv4?(value) |
||||
when :v6 |
||||
record.errors.add(attribute, options[:message] || :ipv6) unless ipv6?(value) |
||||
else |
||||
record.errors.add(attribute, options[:message] || :ip) unless ip?(value) |
||||
end |
||||
end |
||||
private |
||||
# Validates IPv4 address |
||||
# @param [String] address the ipv4 address |
||||
# @return [Boolean] the validation result |
||||
def ipv4?(address) |
||||
address =~ /^ |
||||
(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3} |
||||
(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) |
||||
$/x |
||||
end |
||||
|
||||
# Validates IPv6 address |
||||
# @param [String] address the ipv6 address |
||||
# @return [Boolean] the validation result |
||||
def ipv6?(address) |
||||
address =~ /^ |
||||
( |
||||
(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) |
||||
|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) |
||||
|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) |
||||
|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4}) |
||||
|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4}) |
||||
|(([0-9A-Fa-f]{1,4}:){1,7}:) |
||||
)$/x |
||||
end |
||||
|
||||
# Validates IP (v4 or v6) address |
||||
# @param [String] address the ip address |
||||
# @return [Boolean] the validation result |
||||
def ip?(address) |
||||
ipv4?(address) || ipv6?(address) |
||||
end |
||||
end |
@ -0,0 +1,46 @@
|
||||
# Validates Zone objects |
||||
# |
||||
# @author Kim Nørgaard <jasen@jasen.dk> |
||||
class ZoneValidator < ActiveModel::Validator |
||||
def validate(record) |
||||
record.errors.add(:mname, options[:message] || :mname) if mname_is_zone_name?(record) |
||||
record.errors.add(:base, options[:message] || :missing_ns_record) unless has_two_ns_rr?(record) |
||||
record.errors.add(:mname, options[:message] || :not_a_defined_nameserver) unless mname_is_a_defined_nameserver?(record) |
||||
record.errors.add(:base, options[:message] || :duplicate_nameservers_found) unless nameservers_are_unique?(record) |
||||
end |
||||
|
||||
private |
||||
# Check if the zone name equals the primary nameserver |
||||
# @param [Zone] record The Zone to check |
||||
# @return [Boolean] True if zone name and primary nameserver are identical |
||||
def mname_is_zone_name?(zone) |
||||
zone.name == zone.mname |
||||
end |
||||
|
||||
# Check if the zone has at least two associated NS resource records |
||||
# @param [Zone] zone The Zone to check |
||||
# @return [Boolean] True if the zone has at least two associated NS resource records |
||||
def has_two_ns_rr?(zone) |
||||
zone.ns_resource_records.length >= 2 |
||||
end |
||||
|
||||
# Check if the primary nameserver of the zone is defined as one of the |
||||
# associated NS resource records |
||||
# @param [Zone] zone The Zone to check |
||||
# @return [Boolean] True if the primary nameserver is defined as one of the |
||||
# associated NS resource records |
||||
def mname_is_a_defined_nameserver?(zone) |
||||
unless zone.mname.blank? |
||||
nameservers = zone.ns_resource_records.map(&:rdata) |
||||
nameservers.select {|value| value.downcase == zone.mname.downcase}.size > 0 |
||||
end |
||||
end |
||||
|
||||
# Check if the NS resource records of the zone are unique |
||||
# @param [Zone] zone The Zone to check |
||||
# @return [Boolean] True if the Zone has unique NS resource records associated |
||||
def nameservers_are_unique?(zone) |
||||
nameserver_data_fields = zone.ns_resource_records.map(&:rdata) |
||||
nameserver_data_fields.inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys.empty? |
||||
end |
||||
end |
@ -0,0 +1,21 @@
|
||||
<% |
||||
parent_record = @record |
||||
associated = column.singular_association? ? [parent_record.send(column.name)].compact : parent_record.send(column.name).to_a |
||||
associated = associated.sort_by {|r| r.new_record? ? 99999999999 : r.id} unless column.association.options.has_key?(:order) |
||||
if show_blank_record = column.show_blank_record?(associated) |
||||
child = column.singular_association? ? parent_record.send(:"build_#{column.name}") : parent_record.send(column.name).build |
||||
reflection = parent_record.class.reflect_on_association(column.name) |
||||
if reflection && reflection.reverse |
||||
reverse_macro = child.class.reflect_on_association(reflection.reverse).macro |
||||
child.send(:"#{reflection.reverse}=", parent_record) if [:has_one, :belongs_to].include?(reverse_macro) |
||||
end |
||||
associated << child |
||||
end |
||||
subform_div_id = "#{sub_form_id({:association => column.name, :id => parent_record.id || 99999999999})}-div" |
||||
-%> |
||||
<h5><%= column.label -%></h5> |
||||
<div id ="<%= subform_div_id %>" <%= 'style="display: none;"'.html_safe if column.collapsed -%>> |
||||
<%= render :partial => subform_partial_for_column(column), :locals => {:column => column, :parent_record => parent_record, :associated => associated, :show_blank_record => show_blank_record} %> |
||||
</div> |
||||
<%= link_to_visibility_toggle(subform_div_id, {:default_visible => !column.collapsed}) -%> |
||||
<% @record = parent_record -%> |
@ -0,0 +1,49 @@
|
||||
<% |
||||
# hide "Replace with new" for SOA record |
||||
|
||||
begin |
||||
remote_controller = active_scaffold_controller_for(column.association.klass) |
||||
rescue ActiveScaffold::ControllerNotFound |
||||
remote_controller = nil |
||||
end |
||||
@record = parent_record |
||||
|
||||
show_add_existing = column_show_add_existing(column) |
||||
show_add_new = column_show_add_new(column, associated, @record) |
||||
|
||||
return unless show_add_new or show_add_existing |
||||
|
||||
edit_associated_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :associated_id => '--ID--', :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_existing |
||||
add_new_url = url_for(:action => 'edit_associated', :id => parent_record.id, :association => column.name, :escape => false, :eid => params[:eid], :parent_controller => params[:parent_controller], :parent_id => params[:parent_id]) if show_add_new |
||||
|
||||
-%> |
||||
<div class="footer-wrapper"> |
||||
<div class="footer"> |
||||
<% if show_add_new && column.name != :soa_record -%> |
||||
<% if column.plural_association? |
||||
add_label = as_(:create_another, :model => column.association.klass.model_name.human) |
||||
add_class = 'as_create_another' |
||||
else |
||||
add_label = as_(:replace_with_new) |
||||
add_class = 'as_replace_with_new' |
||||
end |
||||
create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %> |
||||
<%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %> |
||||
<%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %> |
||||
<% end -%> |
||||
|
||||
<%= '|' if show_add_new and show_add_existing %> |
||||
|
||||
<% if show_add_existing -%> |
||||
<% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%> |
||||
<%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{edit_associated_url.to_json}, #{active_scaffold_id.to_json}, id);" -%> |
||||
<% else -%> |
||||
<% select_options = options_for_select(options_for_association(column.association)) |
||||
add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing" %> |
||||
<%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %> |
||||
<%= link_to as_(:add_existing), edit_associated_url, :id => add_existing_id, :remote => true, :class=> column.plural_association? ? 'as_add_existing' : 'as_replace_existing', :style => "display: none;" %> |
||||
<%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %> |
||||
<% end -%> |
||||
<% end -%> |
||||
</div> |
||||
</div> |
@ -1,5 +1,10 @@
|
||||
<div id="footer"> |
||||
<div class="block"> |
||||
<p>Copyright © <%= Time.now.year %> Nicolae Claudius</p> |
||||
<p> |
||||
<a href="#">Terms</a> |
||||
<a href="#">Privacy</a> |
||||
<a href="#">Contact</a> |
||||
© <%= Time.now.year %> Nicolae Claudius |
||||
</p> |
||||
</div> |
||||
</div> |
@ -0,0 +1,13 @@
|
||||
<% columns.each do |column| %> |
||||
<% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%> |
||||
<% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%> |
||||
|
||||
<td class="<%= column_class(column, column_value, record) %>" > |
||||
<% if column.name == :change_date %> |
||||
<% column_value = Time.at(record.change_date) unless record.change_date.nil? # TODO: localize ? %> |
||||
<%= authorized ? render_list_column(column_value, column, record) : column_value %> |
||||
<% else %> |
||||
<%= authorized ? render_list_column(column_value, column, record) : column_value %> |
||||
<% end %> |
||||
</td> |
||||
<% end -%> |
@ -0,0 +1,28 @@
|
||||
set :application, 'simpledns' |
||||
set :domain, 'zooz.dyndns.org' |
||||
set :repository, "set your repository location here" # TODO: write me |
||||
set :repository, "ssh://#{domain}/home/clyfe/dev/#{application}.git" |
||||
set :use_sudo, false |
||||
set :deploy_to, '/srv/www/apps/entrydns' |
||||
set :user, 'clyfe' |
||||
set :scm, 'git' |
||||
|
||||
role :web, domain # Your HTTP server, Apache/etc |
||||
role :app, domain # This may be the same as your `Web` server |
||||
role :db, domain, :primary => true # This is where Rails migrations will run |
||||
# role :db, "your slave db-server here" |
||||
|
||||
namespace :deploy do |
||||
task :start, :roles => :app do |
||||
run "touch #{current_release}/tmp/restart.txt" |
||||
end |
||||
|
||||
task :stop, :roles => :app do |
||||
# Do nothing. |
||||
end |
||||
|
||||
desc "Restart Application" |
||||
task :restart, :roles => :app do |
||||
run "touch #{current_release}/tmp/restart.txt" |
||||
end |
||||
end |
@ -0,0 +1,157 @@
|
||||
require 'spec_helper' |
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator. |
||||
# It demonstrates how one might use RSpec to specify the controller code that |
||||
# was generated by Rails when you ran the scaffold generator. |
||||
# |
||||
# It assumes that the implementation code is generated by the rails scaffold |
||||
# generator. If you are using any extension libraries to generate different |
||||
# controller code, this generated spec may or may not pass. |
||||
# |
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number |
||||
# of tools you can use to make these specs even more expressive, but we're |
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable. |
||||
# |
||||
# Compared to earlier versions of this generator, there is very limited use of |
||||
# stubs and message expectations in this spec. Stubs are only used when there |
||||
# is no simpler way to get a handle on the object needed for the example. |
||||
# Message expectations are only used when there is no simpler way to specify |
||||
# that an instance is receiving a specific message. |
||||
|
||||
describe NsController do |
||||
|
||||
# This should return the minimal set of attributes required to create a valid |
||||
# Ns. As you add validations to Ns, be sure to |
||||
# update the return value of this method accordingly. |
||||
def valid_attributes |
||||
{} |
||||
end |
||||
|
||||
describe "GET index" do |
||||
it "assigns all ns as @ns" do |
||||
ns = Ns.create! valid_attributes |
||||
get :index |
||||
assigns(:ns).should eq([ns]) |
||||
end |
||||
end |
||||
|
||||
describe "GET show" do |
||||
it "assigns the requested ns as @ns" do |
||||
ns = Ns.create! valid_attributes |
||||
get :show, :id => ns.id.to_s |
||||
assigns(:ns).should eq(ns) |
||||
end |
||||
end |
||||
|
||||
describe "GET new" do |
||||
it "assigns a new ns as @ns" do |
||||
get :new |
||||
assigns(:ns).should be_a_new(Ns) |
||||
end |
||||
end |
||||
|
||||
describe "GET edit" do |
||||
it "assigns the requested ns as @ns" do |
||||
ns = Ns.create! valid_attributes |
||||
get :edit, :id => ns.id.to_s |
||||
assigns(:ns).should eq(ns) |
||||
end |
||||
end |
||||
|
||||
describe "POST create" do |
||||
describe "with valid params" do |
||||
it "creates a new Ns" do |
||||
expect { |
||||
post :create, :ns => valid_attributes |
||||
}.to change(Ns, :count).by(1) |
||||
end |
||||
|
||||
it "assigns a newly created ns as @ns" do |
||||
post :create, :ns => valid_attributes |
||||
assigns(:ns).should be_a(Ns) |
||||
assigns(:ns).should be_persisted |
||||
end |
||||
|
||||
it "redirects to the created ns" do |
||||
post :create, :ns => valid_attributes |
||||
response.should redirect_to(Ns.last) |
||||
end |
||||
end |
||||
|
||||
describe "with invalid params" do |
||||
it "assigns a newly created but unsaved ns as @ns" do |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Ns.any_instance.stub(:save).and_return(false) |
||||
post :create, :ns => {} |
||||
assigns(:ns).should be_a_new(Ns) |
||||
end |
||||
|
||||
it "re-renders the 'new' template" do |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Ns.any_instance.stub(:save).and_return(false) |
||||
post :create, :ns => {} |
||||
response.should render_template("new") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "PUT update" do |
||||
describe "with valid params" do |
||||
it "updates the requested ns" do |
||||
ns = Ns.create! valid_attributes |
||||
# Assuming there are no other ns in the database, this |
||||
# specifies that the Ns created on the previous line |
||||
# receives the :update_attributes message with whatever params are |
||||
# submitted in the request. |
||||
Ns.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) |
||||
put :update, :id => ns.id, :ns => {'these' => 'params'} |
||||
end |
||||
|
||||
it "assigns the requested ns as @ns" do |
||||
ns = Ns.create! valid_attributes |
||||
put :update, :id => ns.id, :ns => valid_attributes |
||||
assigns(:ns).should eq(ns) |
||||
end |
||||
|
||||
it "redirects to the ns" do |
||||
ns = Ns.create! valid_attributes |
||||
put :update, :id => ns.id, :ns => valid_attributes |
||||
response.should redirect_to(ns) |
||||
end |
||||
end |
||||
|
||||
describe "with invalid params" do |
||||
it "assigns the ns as @ns" do |
||||
ns = Ns.create! valid_attributes |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Ns.any_instance.stub(:save).and_return(false) |
||||
put :update, :id => ns.id.to_s, :ns => {} |
||||
assigns(:ns).should eq(ns) |
||||
end |
||||
|
||||
it "re-renders the 'edit' template" do |
||||
ns = Ns.create! valid_attributes |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Ns.any_instance.stub(:save).and_return(false) |
||||
put :update, :id => ns.id.to_s, :ns => {} |
||||
response.should render_template("edit") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "DELETE destroy" do |
||||
it "destroys the requested ns" do |
||||
ns = Ns.create! valid_attributes |
||||
expect { |
||||
delete :destroy, :id => ns.id.to_s |
||||
}.to change(Ns, :count).by(-1) |
||||
end |
||||
|
||||
it "redirects to the ns list" do |
||||
ns = Ns.create! valid_attributes |
||||
delete :destroy, :id => ns.id.to_s |
||||
response.should redirect_to(ns_index_url) |
||||
end |
||||
end |
||||
|
||||
end |
@ -0,0 +1,157 @@
|
||||
require 'spec_helper' |
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator. |
||||
# It demonstrates how one might use RSpec to specify the controller code that |
||||
# was generated by Rails when you ran the scaffold generator. |
||||
# |
||||
# It assumes that the implementation code is generated by the rails scaffold |
||||
# generator. If you are using any extension libraries to generate different |
||||
# controller code, this generated spec may or may not pass. |
||||
# |
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number |
||||
# of tools you can use to make these specs even more expressive, but we're |
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable. |
||||
# |
||||
# Compared to earlier versions of this generator, there is very limited use of |
||||
# stubs and message expectations in this spec. Stubs are only used when there |
||||
# is no simpler way to get a handle on the object needed for the example. |
||||
# Message expectations are only used when there is no simpler way to specify |
||||
# that an instance is receiving a specific message. |
||||
|
||||
describe SoasController do |
||||
|
||||
# This should return the minimal set of attributes required to create a valid |
||||
# Soa. As you add validations to Soa, be sure to |
||||
# update the return value of this method accordingly. |
||||
def valid_attributes |
||||
{} |
||||
end |
||||
|
||||
describe "GET index" do |
||||
it "assigns all soas as @soas" do |
||||
soa = Soa.create! valid_attributes |
||||
get :index |
||||
assigns(:soas).should eq([soa]) |
||||
end |
||||
end |
||||
|
||||
describe "GET show" do |
||||
it "assigns the requested soa as @soa" do |
||||
soa = Soa.create! valid_attributes |
||||
get :show, :id => soa.id.to_s |
||||
assigns(:soa).should eq(soa) |
||||
end |
||||
end |
||||
|
||||
describe "GET new" do |
||||
it "assigns a new soa as @soa" do |
||||
get :new |
||||
assigns(:soa).should be_a_new(Soa) |
||||
end |
||||
end |
||||
|
||||
describe "GET edit" do |
||||
it "assigns the requested soa as @soa" do |
||||
soa = Soa.create! valid_attributes |
||||
get :edit, :id => soa.id.to_s |
||||
assigns(:soa).should eq(soa) |
||||
end |
||||
end |
||||
|
||||
describe "POST create" do |
||||
describe "with valid params" do |
||||
it "creates a new Soa" do |
||||
expect { |
||||
post :create, :soa => valid_attributes |
||||
}.to change(Soa, :count).by(1) |
||||
end |
||||
|
||||
it "assigns a newly created soa as @soa" do |
||||
post :create, :soa => valid_attributes |
||||
assigns(:soa).should be_a(Soa) |
||||
assigns(:soa).should be_persisted |
||||
end |
||||
|
||||
it "redirects to the created soa" do |
||||
post :create, :soa => valid_attributes |
||||
response.should redirect_to(Soa.last) |
||||
end |
||||
end |
||||
|
||||
describe "with invalid params" do |
||||
it "assigns a newly created but unsaved soa as @soa" do |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Soa.any_instance.stub(:save).and_return(false) |
||||
post :create, :soa => {} |
||||
assigns(:soa).should be_a_new(Soa) |
||||
end |
||||
|
||||
it "re-renders the 'new' template" do |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Soa.any_instance.stub(:save).and_return(false) |
||||
post :create, :soa => {} |
||||
response.should render_template("new") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "PUT update" do |
||||
describe "with valid params" do |
||||
it "updates the requested soa" do |
||||
soa = Soa.create! valid_attributes |
||||
# Assuming there are no other soas in the database, this |
||||
# specifies that the Soa created on the previous line |
||||
# receives the :update_attributes message with whatever params are |
||||
# submitted in the request. |
||||
Soa.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) |
||||
put :update, :id => soa.id, :soa => {'these' => 'params'} |
||||
end |
||||
|
||||
it "assigns the requested soa as @soa" do |
||||
soa = Soa.create! valid_attributes |
||||
put :update, :id => soa.id, :soa => valid_attributes |
||||
assigns(:soa).should eq(soa) |
||||
end |
||||
|
||||
it "redirects to the soa" do |
||||
soa = Soa.create! valid_attributes |
||||
put :update, :id => soa.id, :soa => valid_attributes |
||||
response.should redirect_to(soa) |
||||
end |
||||
end |
||||
|
||||
describe "with invalid params" do |
||||
it "assigns the soa as @soa" do |
||||
soa = Soa.create! valid_attributes |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Soa.any_instance.stub(:save).and_return(false) |
||||
put :update, :id => soa.id.to_s, :soa => {} |
||||
assigns(:soa).should eq(soa) |
||||
end |
||||
|
||||
it "re-renders the 'edit' template" do |
||||
soa = Soa.create! valid_attributes |
||||
# Trigger the behavior that occurs when invalid params are submitted |
||||
Soa.any_instance.stub(:save).and_return(false) |
||||
put :update, :id => soa.id.to_s, :soa => {} |
||||
response.should render_template("edit") |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe "DELETE destroy" do |
||||
it "destroys the requested soa" do |
||||
soa = Soa.create! valid_attributes |
||||
expect { |
||||
delete :destroy, :id => soa.id.to_s |
||||
}.to change(Soa, :count).by(-1) |
||||
end |
||||
|
||||
it "redirects to the soas list" do |
||||
soa = Soa.create! valid_attributes |
||||
delete :destroy, :id => soa.id.to_s |
||||
response.should redirect_to(soas_url) |
||||
end |
||||
end |
||||
|
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
# Specs in this file have access to a helper object that includes |
||||
# the NsHelper. For example: |
||||
# |
||||
# describe NsHelper do |
||||
# describe "string concat" do |
||||
# it "concats two strings with spaces" do |
||||
# helper.concat_strings("this","that").should == "this that" |
||||
# end |
||||
# end |
||||
# end |
||||
describe NsHelper do |
||||
pending "add some examples to (or delete) #{__FILE__}" |
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
# Specs in this file have access to a helper object that includes |
||||
# the SoAsHelper. For example: |
||||
# |
||||
# describe SoAsHelper do |
||||
# describe "string concat" do |
||||
# it "concats two strings with spaces" do |
||||
# helper.concat_strings("this","that").should == "this that" |
||||
# end |
||||
# end |
||||
# end |
||||
describe SoAsHelper do |
||||
pending "add some examples to (or delete) #{__FILE__}" |
||||
end |
@ -0,0 +1,11 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "Ns" do |
||||
describe "GET /ns" do |
||||
it "works! (now write some real specs)" do |
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers |
||||
get ns_index_path |
||||
response.status.should be(200) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "Soas" do |
||||
describe "GET /soas" do |
||||
it "works! (now write some real specs)" do |
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers |
||||
get soas_path |
||||
response.status.should be(200) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,35 @@
|
||||
require "spec_helper" |
||||
|
||||
describe NsController do |
||||
describe "routing" do |
||||
|
||||
it "routes to #index" do |
||||
get("/ns").should route_to("ns#index") |
||||
end |
||||
|
||||
it "routes to #new" do |
||||
get("/ns/new").should route_to("ns#new") |
||||
end |
||||
|
||||
it "routes to #show" do |
||||
get("/ns/1").should route_to("ns#show", :id => "1") |
||||
end |
||||
|
||||
it "routes to #edit" do |
||||
get("/ns/1/edit").should route_to("ns#edit", :id => "1") |
||||
end |
||||
|
||||
it "routes to #create" do |
||||
post("/ns").should route_to("ns#create") |
||||
end |
||||
|
||||
it "routes to #update" do |
||||
put("/ns/1").should route_to("ns#update", :id => "1") |
||||
end |
||||
|
||||
it "routes to #destroy" do |
||||
delete("/ns/1").should route_to("ns#destroy", :id => "1") |
||||
end |
||||
|
||||
end |
||||
end |
@ -0,0 +1,35 @@
|
||||
require "spec_helper" |
||||
|
||||
describe SoasController do |
||||
describe "routing" do |
||||
|
||||
it "routes to #index" do |
||||
get("/soas").should route_to("soas#index") |
||||
end |
||||
|
||||
it "routes to #new" do |
||||
get("/soas/new").should route_to("soas#new") |
||||
end |
||||
|
||||
it "routes to #show" do |
||||
get("/soas/1").should route_to("soas#show", :id => "1") |
||||
end |
||||
|
||||
it "routes to #edit" do |
||||
get("/soas/1/edit").should route_to("soas#edit", :id => "1") |
||||
end |
||||
|
||||
it "routes to #create" do |
||||
post("/soas").should route_to("soas#create") |
||||
end |
||||
|
||||
it "routes to #update" do |
||||
put("/soas/1").should route_to("soas#update", :id => "1") |
||||
end |
||||
|
||||
it "routes to #destroy" do |
||||
delete("/soas/1").should route_to("soas#destroy", :id => "1") |
||||
end |
||||
|
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "ns/edit.html.erb" do |
||||
before(:each) do |
||||
@ns = assign(:ns, stub_model(Ns)) |
||||
end |
||||
|
||||
it "renders the edit ns form" do |
||||
render |
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers |
||||
assert_select "form", :action => ns_index_path(@ns), :method => "post" do |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "ns/index.html.erb" do |
||||
before(:each) do |
||||
assign(:ns, [ |
||||
stub_model(Ns), |
||||
stub_model(Ns) |
||||
]) |
||||
end |
||||
|
||||
it "renders a list of ns" do |
||||
render |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "ns/new.html.erb" do |
||||
before(:each) do |
||||
assign(:ns, stub_model(Ns).as_new_record) |
||||
end |
||||
|
||||
it "renders new ns form" do |
||||
render |
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers |
||||
assert_select "form", :action => ns_index_path, :method => "post" do |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,11 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "ns/show.html.erb" do |
||||
before(:each) do |
||||
@ns = assign(:ns, stub_model(Ns)) |
||||
end |
||||
|
||||
it "renders attributes in <p>" do |
||||
render |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "soas/edit.html.erb" do |
||||
before(:each) do |
||||
@soa = assign(:soa, stub_model(Soa)) |
||||
end |
||||
|
||||
it "renders the edit soa form" do |
||||
render |
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers |
||||
assert_select "form", :action => soas_path(@soa), :method => "post" do |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,14 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "soas/index.html.erb" do |
||||
before(:each) do |
||||
assign(:soas, [ |
||||
stub_model(Soa), |
||||
stub_model(Soa) |
||||
]) |
||||
end |
||||
|
||||
it "renders a list of soas" do |
||||
render |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
require 'spec_helper' |
||||
|
||||
describe "soas/new.html.erb" do |
||||
before(:each) do |
||||
assign(:soa, stub_model(Soa).as_new_record) |
||||
end |
||||
|
||||
it "renders new soa form" do |
||||
render |
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers |
||||
assert_select "form", :action => soas_path, :method => "post" do |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue