Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Smythe
Oct 12, 2003
in the past and then ur looking and thinking "uhhhhhhhhh.. wow this poo poo is FuckTarded!!!"

Adbot
ADBOT LOVES YOU

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
5 years try 5 days :shepface:

pram
Jun 10, 2001
my terrible code from 5 years ago is still running at a bank and thats exactly what id say about it and id even make that face

elite_garbage_man
Apr 3, 2010
I THINK THAT "PRIMA DONNA" IS "PRE-MADONNA". I MAY BE ILLITERATE.
I hosed up hello world

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
code:
require "./logger"
require "http"
require "./html/*"
require "./html/builder2"


abstract class Dorker::Controller
  include Dorker::Logger

  @headers :: HTTP::Headers
  struct RestMethod; end
  struct Get < RestMethod; end
  struct Post < RestMethod; end

  alias GET = Get.class
  alias POST = Post.class
    
  enum Method
    GET 
    POST

    def rest
      case self
      when GET; Get
      when POST; Post
      else
        RestMethod
      end
    end
  end

  def respond(id, action, method)
    log.info  "no method for #{id}, #{action}, #{method} on #{self.class}"
    HTTP::Response.not_found
  end

  def respond(action, method)
    log.info  "no method for #{action}, #{method}"
    HTTP::Response.not_found
  end
  def respond(method)
    log.info  "no method for #{method}"
    HTTP::Response.not_found
  end

  macro action(name, method, id = nil, &block)
    {% if !block.args.empty? %}
      
      def respond(%id, %m : {{name.id.upcase}}, %t : {{method}})
         {{block.args.first}} = %id
         {{block.body}}
      end
    {% else %} def respond(%m : {{name.id.upcase}}, %t : {{method}})
         {{block.body}}
       end
    {% end %}

  end

 abstract def parse_endpoint
 def dynamic_dispatcher
    path = @request.path

    tuple = @dispatch_tuple
    id = tuple[0]
    action = tuple[1]
    method = tuple[2]

    if id && action 
      log.info("Dispatching #{path} with #{id}, #{action}, #{method}" )
      respond(id, action, method)
    elsif id && !action 
      log.info("Dispatching #{path} with #{id}, #{method}" )
      respond(id, method)
    elsif action && !id
      log.info("Dispatching #{path} with #{action}, #{method}")
      respond(action, method)
    else
      log.info("Dispatching #{path} with #{method}")
      respond(method)
    end
  end
  property :headers, :status, :body

  def initialize(req : Dorker::RequestObject, match_data)
    @request = req
    @headers = HTTP::Headers.new
    @status = 200
    @body = ""
    @params = req.params
    action = match_data["method"]? || "index"
    action = action ? parse_endpoint(action).meth : nil
    id = match_data["id"]?
    method = Method.parse(@request.method).rest
    @dispatch_tuple = Tuple.new(id, action,  method)
    @context = RenderContext.new()
  end

  def dispatch
    dynamic_dispatcher
    to_response
  end

  macro endpoints(*endpoints)
    enum Endpoint
      {% for endpoint in endpoints %}
        {{endpoint.id.upcase}}
      {% end %}      
      def meth
        case self 
          {% for endpoint in endpoints %}
          when {{endpoint.id.upcase}}
            {{@type}}::{{endpoint.id.capitalize}}
          {% end %}      
        else
          nil
        end
      end
    end

    {% for endpoint in endpoints %}
      record {{endpoint.id.capitalize}}
      alias {{endpoint.id.upcase}} = {{@type}}::{{endpoint.id.capitalize}}.class
    {% end %}
  end

  macro inherited
    macro def parse_endpoint(endpoint) : Endpoint
      Endpoint.parse(endpoint)
    end
 
    Dorker::Router.routes[{{PATH}}] = {{@type}}
  end

   
  def render(k : Symbol)
    Attr.modifier(:active_tab) do |attr, args, ctx|
      ctx.active_tab == args ?  attr.append_attr(:class, "active") : attr
    end

    case k
    when :body
      @body = Dorker::HTML::Body.yield_into(@context) do |body|
        yield(body)
      end
    end
  end

  def to_response : HTTP::Response
    headers.add("Content-type", "text/html") if !headers.has_key?("Content-type")
    HTTP::Response.new(status, body, headers )
  end
end

echinopsis
Apr 13, 2004

by Fluffdaddy
same but structural foundations

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
that feel when u forgot what that code does from last week


OR

that feel when u go to implement somethign but u already did it yesterday but its not what you were expecting

flakeloaf
Feb 26, 2003

Still better than android clock

i made a magic spell
it turns any code anywhere into something you wrote
the magic words are "christ almighty which one of you defective morons wrote this garbage"

Migishu
Oct 22, 2005

I'll eat your fucking eyeballs if you're not careful

Grimey Drawer
"what the gently caress is this poo poo"

Migishu
Oct 22, 2005

I'll eat your fucking eyeballs if you're not careful

Grimey Drawer
also a perfect descriptor for my are posting

Valeyard
Mar 30, 2012


Grimey Drawer
*opens up notepad full of gta weapon cheats* hmm

*pedestrian riot* hell yeah

*cars fly like dodo* :vince:

Valeyard
Mar 30, 2012


Grimey Drawer

pram
Jun 10, 2001

lmao

Adbot
ADBOT LOVES YOU

jony ive aces
Jun 14, 2012

designer of the lomarf car


Buglord
cool soft tabs idiot, nice work

  • Locked thread