grack_helpers.rb 674 Bytes
Newer Older
1 2 3
module Grack
  module Helpers
    def project_by_path(path)
4
      if m = /^([\w\.\/-]+)\.git/.match(path).to_a
5
        path_with_namespace = m.last
6
        path_with_namespace.gsub!(/\.wiki$/, '')
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

        Project.find_with_namespace(path_with_namespace)
      end
    end

    def render_not_found
      [404, {"Content-Type" => "text/plain"}, ["Not Found"]]
    end

    def can?(object, action, subject)
      abilities.allowed?(object, action, subject)
    end

    def abilities
      @abilities ||= begin
                       abilities = Six.new
                       abilities << Ability
                       abilities
                     end
    end
  end
end