class DitzStr::DitzStrServlet

Public Class Methods

new(server, options) click to toggle source
Calls superclass method
# File lib/ditzstr/brick.rb, line 126
def initialize(server, options)
        super(server)
        @project = options[:project]
        @config = options[:config]
        @brickview = options[:brickview]
        @sharedir = options[:dir]
        @user = options[:user]
end

Public Instance Methods

do_GET(req,resp) click to toggle source
# File lib/ditzstr/brick.rb, line 135
def do_GET(req,resp)
        if req.path=="/index.html" or req.path=="/"
                #puts req.query['wee']
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_index 
        elsif req.path.start_with? '/release-'
                relname = req.path.sub('/release-','').sub('.html','')
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_release relname
        elsif req.path.start_with? '/component-'
                compname = req.path.sub('/component-','').sub('.html','')
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_component compname
        elsif req.path.start_with? '/issue-'
                issuename = req.path.sub('/issue-','').sub('.html','')
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_issue issuename
        elsif req.path=='/new_issue.html'
                options = {}
                if req.query['component']!=nil
                        options[:component] = req.query['component']
                end
                if req.query['release']!=nil
                        options[:release] = req.query['release']
                end
                options[:creator] = @user
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_new_issue options
        elsif req.path=='/new_component.html'
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_new_component
        elsif req.path=='/new_release.html'
                resp['content-type'] = 'text/html'
                resp.body = @brickview.generate_new_release
        elsif req.path=='/close.html'
                resp['content-type'] = 'text/html'
                if req.query['issue']==nil
                        resp.body = 'Error, no such issue found.'
                else
                        resp.body = @brickview.generate_close_issue req.query['issue'], req.query['disposition']
                end
        else
                HTTPServlet::FileHandler.new(@server,@sharedir).do_GET(req,resp)
        end
end
do_POST(req,resp) click to toggle source
# File lib/ditzstr/brick.rb, line 181
def do_POST(req,resp)
        resp['content-type'] = 'text/html'

        if req.path.start_with? '/new_issue.html'
                issue = Issue.create({:project => @project, :config=> @config},{:title => req.query['title'], :desc => req.query['description'], :type => req.query['type'], 
                              :component => req.query['component'], :release => req.query['release'], :reporter => 'poop', :comments => req.query['comments']});
                issue.log "created", @config.user, req.query['comments']
                resp.body = "<html><head><meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=/component-#{req.query['component']}.html\"></head><body>Redirecting...</body></html>"
                @project.add_issue issue
                @project.assign_issue_names!
        elsif req.path.start_with? '/edit_issue.html'

        elsif req.path.start_with? '/new_component.html'
                component = Component.create({:project => @project, :config=>@config},{:name => req.query['name']});
                @project.add_component component
                resp.body = "<html><head><meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=/index.html\"></head><body>Redirecting...</body></html>"
        elsif req.path.start_with? '/new_release.html'
                release = Release.create({:project => @project, :config=>@config},{:name => req.query['name']})
                release.log "created", @config.user, req.query['comments']
                @project.add_release release
                resp.body = "<html><head><meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=/index.html\"></head><body>Redirecting...</body></html>"
        elsif req.path.start_with? '/issue-'

                issue = "#{req.path}"
                issue = issue.gsub('/issue-','')
                issue = issue.gsub('.html','')
                resp.body = @brickview.comment_on_issue issue, req.query['comment']
        elsif req.path.start_with? '/close.html'
                issue_id = req.query['issue']
                comment = req.query['comment']
                closer = req.query['closer']
                disp = req.query['disposition']

                issue_res = @brickview.get_issue_by_name issue_id
                
                if issue_res[0]
                        iss = issue_res[1]
                        iss.close disp.to_sym, closer, comment
                        resp.body = "<html><head><meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=/issue-#{issue_id}.html\"></head><body>Redirecting...</body></html>"
                else
                        return issue_res[1]
                end
        end
end