Sha256: a40070cce206afdb0c524bc08d703b80ca525451da48e60729222d1340dbcef0

Contents?: true

Size: 921 Bytes

Versions: 4

Compression:

Stored size: 921 Bytes

Contents

import java.lang.System
import java.io.File
import stdlib.Array
import stdlib.Io

class SourceController < ApplicationController

  # GET /source/*
  def doGet(request, response)
    @base = request.getRequestURI
    @base += '/' unless @base.endsWith('/')
  # @path = request.getPathInfo || "" # (index).html added
    @path = @base.substring(7, @base.length - 1)
    node = File.new(System.getProperty('user.dir') + @path)
    if node.isDirectory
      @entries = Array.sort(node.listFiles)
      response.getWriter.write(list_erb)
    else
      if @path.matches "^\/public\/.+\.(ico|gif|jpe?g|png)$"
        response.sendRedirect @path.substring(7, @path.length); nil
      else
        @content = node.isFile ? Io.read(node) : 'Sorry, no file'
        response.getWriter.write(show_erb)
      end
    end
  end

  def_edb(show_erb, 'views/source/show.html.erb')
  def_edb(list_erb, 'views/source/list.html.erb')
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dubious-0.0.3-java examples/contacts/app/controllers/source_controller.mirah
dubious-0.0.2-java examples/contacts/app/controllers/source_controller.mirah
dubious-0.0.1-java examples/contacts/app/controllers/source_controller.mirah
dubious-0.0.0-java examples/contacts/app/controllers/source_controller.mirah