Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
9 this may or may not hold the power I need :p

Code:
if conf.friendly_urls then
    uri_map = { -- URI remapping
        match = "^[^%./]*/?([^%.]*)$",
        with = redirect,
        params = {
            "/",
            function(req,res,cap)
                local vars = {}

                for var in string.gmatch(cap[1], '([^/]+)') do
                    table.insert(vars,var)
                end

                if #vars > 0 then
                    local mod = (#vars % 2) - 1
                    local get = ""

                    if #vars > 1 - mod then
                        for i = 2 - mod, #vars, 2 do
                            get = get.."&"..vars[i].."="..vars[i+1]
                        end
                    end

                    if mod == -1 then
                        get = vars[2]..get
                    end

                    req.cmd_url = "/index.lua?"..conf.route_parameter.."="..vars[1].."/"..get
                else
                    req.cmd_url = "/index.lua"
                end
              
                return "reparse"
            end
        }
    }
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
4 I may have found a way to always execute 1 function.
Now, lets see how I can use this :p

edit:3
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
1 YES!!! I can send plain text using that function, now lets see if it will indeed always be executed :p
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
50 It also will always be executed just like I taught it would.
Thus what I now need to do is hook my framework to this function and add a function to write plain text.
After that I need to somehow hook xavante up with CGILua and add a function in my framework to tell Xavante what to render.

(I also need to finish the query builder and add an to_json function)
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
48 I also found the way to get the whole path :)
Now, I need to choose between keeping the current route system and having an unusual route system or to redo it.....
I could also keep this system and have users edit the start-server if they actually want to make advanced use of my route system...that also sounds like a nice way
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
50 and it looks like I got my helper module to load, which might also have loaded the database module. Considering those are pretty much the whole framework right now, that is good.
Next step: get the routes to work :p
(Which need some changes in the code)
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
50 Because now the urls start with a "/" >_<
I guess I need to look up the functions for string manipulation again so I can remove that thing >_<