-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By appending `/gallery`, you can view the list of all past drawings from the lobby. The link will work after the lobby dies, if the data is still in your session storage. We try to avoid sending requests multiple times by caching. In order to do this, we've refactored parts of the lobby, moving shared drawing / color code into draw.js (previously floodfill.js).
- Loading branch information
1 parent
20055f2
commit 6245230
Showing
14 changed files
with
613 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package frontend | ||
|
||
import ( | ||
"log" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/go-chi/chi/v5" | ||
"github.com/scribble-rs/scribble.rs/internal/translations" | ||
) | ||
|
||
type galleryPageData struct { | ||
*BasePageConfig | ||
|
||
LobbyID string | ||
Translation translations.Translation | ||
Locale string | ||
} | ||
|
||
func (handler *SSRHandler) ssrGallery(writer http.ResponseWriter, request *http.Request) { | ||
userAgent := strings.ToLower(request.UserAgent()) | ||
if !isHumanAgent(userAgent) { | ||
// FIXME Handle robots | ||
return | ||
} | ||
|
||
lobbyId := chi.URLParam(request, "lobby_id") | ||
translation, locale := determineTranslation(request) | ||
pageData := &galleryPageData{ | ||
BasePageConfig: handler.basePageConfig, | ||
LobbyID: lobbyId, | ||
Translation: translation, | ||
Locale: locale, | ||
} | ||
|
||
// If the pagedata isn't initialized, it means the synchronized block has exited. | ||
// In this case we don't want to template the lobby, since an error has occurred | ||
// and probably already has been handled. | ||
if err := pageTemplates.ExecuteTemplate(writer, "gallery-page", pageData); err != nil { | ||
log.Printf("Error templating lobby: %s\n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.