Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root directory is cluttered. Move files to a folder. #102

Open
marcoskirsch opened this issue Jul 3, 2017 · 6 comments
Open

Root directory is cluttered. Move files to a folder. #102

marcoskirsch opened this issue Jul 3, 2017 · 6 comments

Comments

@marcoskirsch
Copy link
Owner

When this project started, all the server code was in a single file. Now it's spread across lots of little files, all in the root directory:

httpserver-b64decode.lua
httpserver-basicauth.lua
httpserver-compile.lua
httpserver-conf.lua
httpserver-connection.lua
httpserver-error.lua
httpserver-header.lua
httpserver-init.lua
httpserver-request.lua
httpserver-static.lua
httpserver-wifi.lua
httpserver.lua

I'm toying with the idea of reorganizing and moving all the server files into a folder. I'd remove the prefix to each file. The folder may be named httpserver/ or simply server/

I'm not about to go and do this, as it can be pretty disruptive to other contributors. So I'm floating the idea here in order to get some feedback.

Thanks!

@HHHartmann
Copy link
Contributor

While on the one hand that seems a good Idea on the other hand it is difficult if the files are named differently on the computer and the ESP.
It works fine with the install script but when you use a different tool to transfer files you always have to rename them by hand.
I think a naming schema as now is fine.

@marcoskirsch
Copy link
Owner Author

How do you transfer files to the NodeMCU?

@ATAMAH
Copy link
Contributor

ATAMAH commented Jul 4, 2017

I am using this code in init.lua:

local compileAndRemove = function()
	for name in pairs(file.list()) do
		local isHttpFile = string.match(name, "^(http/)")
		local isCompiled = string.match(name, ".+(\.lc)$")
		local isLuaScript = string.match(name, ".+(\.lua)$")
		
		if (name ~= 'init.lua') and (name ~= 'init_start.lua') and (name ~= 'LLbin.lua') then
			if (not isHttpFile) and (not isCompiled) then
				if isLuaScript then
					if file.open(name) then
						file.close(name)
						file.remove(string.sub(name, 0, -3) .. "lc")
						print('Compiling:', name)
						node.compile(name)
						file.remove(name)
					end
				end
			end
		end
	end
end

local renameAndRemove = function()
	for name in pairs(file.list()) do
		local isHttpFile = string.match(name, "^(http/)")
		local isServerFile = string.match(name, "^(httpserver)")
		
		if (name ~= 'init.lua') and (name ~= 'init_start.lua') and (name ~= 'LLbin.lua') then
			if (not isHttpFile) and (not isServerFile) then
				if file.open(name) then
					file.close(name)
					print('Moving:', name)
					file.remove("http/"..name)					
					file.rename(name,"http/"..name)
					file.remove(name)
				end
			end
		end
	end
end

It automatically compiling all ".lua" files and move all files named not "^httpserver*" to "http/". Maybe somebody can make PR from this code.

@HHHartmann
Copy link
Contributor

@marcelstoer currently I use ESPlorer. I don't want to install python on my (windows) machine right now.
I would like to switch to ftp some time.

I also have a similar script to rename the http files after upload, but not as sophisticated as @ATAMAH s
It has an explicit list of files, as I am also storing other files in the root directory.

@marcelstoer
Copy link
Contributor

@HHHartmann did you mean to tag @marcoskirsch rather than me?

@CharlesScoville
Copy link

How do you transfer files to the NodeMCU?

I've customized my fork of ESPlorer to give a "Save Folder" button specifically so I could work with this project. It also has a dist dir with a prebuilt jar, for those who don't want to download the entire SDK and compile.

:3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants