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

Using zipfs to provide individual unique web pages to each created room? #29

Open
lonnietc opened this issue Feb 4, 2022 · 4 comments

Comments

@lonnietc
Copy link

lonnietc commented Feb 4, 2022

Hello,

I have just come across NilTalk and really like it as I can learn a lot as well.

One thing that I have also been thinking is about how to have a complete set of independent web pages for each room created and have been investigating ZIPFS (https://github.com/spkg/zipfs) for possible use in this way as it allows for a ZIP compressed set of files to be stored in a single file.

I have done some simple tests with ZIPFS and they work:


package main

import (
	"log"
	"net/http"
	"github.com/spkg/zipfs"
)

func main() {
	fs, err := zipfs.New("testdata/testdata.zip")
	if err != nil {
		log.Fatalf("Error setting up zipfs: %v", err)
	}

	log.Fatal(http.ListenAndServe(":8080", zipfs.FileServer(fs)))
}

I was wondering how I might be able to make changes to the NilTalk code that would allow a user to select one of the created and compressed zip "Themes" that could be all stored in a directory and then they could choose one when they create the room or leave it to the default NilTalk theme, but I am not sure what changes might need to be made.

Can you please advise what might be able to be done?
Thanks in advance

@knadh
Copy link
Owner

knadh commented Feb 4, 2022

Hi @lonnietc.

The static assets are all embedded in the binary using stuffbin. You don't need another tool like zipfs. To create multiple room themes, you could copy room.html to room1.html, room2.html etc., changing the template name defined in them accordingly to "room1", "room2" etc. These templates will automatically be loaded and be available for rendering.

Then, the required template can be loaded here ("room1", "room2" etc.):

respondHTML("room", out, http.StatusOK, w, app)

However, you'll need to add room selection to the main form, store that in the Room struct in Redis to use it later

type Room struct {

@lonnietc
Copy link
Author

lonnietc commented Feb 4, 2022

Thanks for getting back to me on this.

Actually, what I am looking for is to be able to develop independent room "websites" that might have an index.html that is a template but that each room site also could have its own JavaScrip, CSS, and other html files that are completely unrelated to the way that you have described.

I also know that you are using stuffbin, but it serves a different purpose than what I need.

I want to have a sub-directory in the site that might be called "roomsites" and within this directory to have a room1.zip, room2.zip, etc..

Each zip is basically a compressed set of files uniquely for that room and not dependent upon any other main files in the existing NilTalk "static" or "template" directory as it will have its template, probably called instex.html or room.html but specifically customized for that room website.

Then I can easily add more roomN.zip files to the roomsites and add their entry for the user to select. Or, I might have the code read in the roomsites directory when it starts and automatically populate a dropdown for the user to choose.

This is also just for experimentation on this idea and I really want to see if it can work by using the roomN.zip compressed files idea if at all possible so any help that you could provide would be truly appreciated.

@lonnietc
Copy link
Author

lonnietc commented Feb 4, 2022

as a follow-on, I am also using In-Memory for development and testing, but really want to try to incorporate the zipfs tool.

@knadh
Copy link
Owner

knadh commented Feb 5, 2022

Yeah, that should also be possible. The program already takes a --static-dir flag with which it is possible to specify a custom path to the static directory, which means there's already provision to load the entire theme from custom locations. This could be extended to work dynamically.

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

No branches or pull requests

2 participants