diff --git a/Handler/Activate.hs b/Handler/Activate.hs index f18f1c7..616335a 100644 --- a/Handler/Activate.hs +++ b/Handler/Activate.hs @@ -18,6 +18,7 @@ getActivateR token = do user <- runDB $ getJust (fromJust $ tokenUser uToken) hexSalt <- return $ toHex $ userSalt user defaultLayout $ do + setTitle "Activate your account" $(widgetFile "activate") _ -> do setMessage "Invalid token!" diff --git a/Handler/Admin.hs b/Handler/Admin.hs index 35d4cb6..367dafe 100644 --- a/Handler/Admin.hs +++ b/Handler/Admin.hs @@ -12,6 +12,7 @@ getAdminR = do case userAdmin user of True -> do defaultLayout $ do + setTitle "Administration: Menu" $(widgetFile "adminBase") False -> do setMessage "You have no admin rights" diff --git a/Handler/AdminAlbumSettings.hs b/Handler/AdminAlbumSettings.hs index fae2106..4a7f0c2 100644 --- a/Handler/AdminAlbumSettings.hs +++ b/Handler/AdminAlbumSettings.hs @@ -16,6 +16,7 @@ getAdminAlbumsR = do True -> do albums <- runDB $ selectList [] [Asc AlbumTitle] defaultLayout $ do + setTitle "Administration: Albums" $(widgetFile "adminAlbums") False -> do setMessage "You are no admin" @@ -38,6 +39,7 @@ getAdminAlbumMediaR albumId = do Just album -> do media <- runDB $ selectList [MediumAlbum ==. albumId] [Asc MediumTitle] defaultLayout $ do + setTitle "Administration: Album media" $(widgetFile "adminAlbumMedia") Nothing -> do setMessage "This album does not exist" @@ -63,6 +65,7 @@ getAdminAlbumSettingsR albumId = do Just album -> do (adminAlbumSettingsWidget, enctype) <- generateFormPost $ adminAlbumSettingsForm album albumId defaultLayout $ do + setTitle "Administration: Album settings" $(widgetFile "adminAlbumSet") Nothing -> do setMessage "This album does not exist" diff --git a/Handler/AdminMediumSettings.hs b/Handler/AdminMediumSettings.hs index daf0f71..93c0529 100644 --- a/Handler/AdminMediumSettings.hs +++ b/Handler/AdminMediumSettings.hs @@ -16,6 +16,7 @@ getAdminMediaR = do True -> do media <- runDB $ selectList [] [Asc MediumTitle] defaultLayout $ do + setTitle "Administration: Media" $(widgetFile "adminMedia") False -> do setMessage "You are no admin" @@ -38,6 +39,7 @@ getAdminMediumSettingsR mediumId = do Just medium -> do (adminMediumSetWidget, enctype) <- generateFormPost $ adminMediumSetForm medium defaultLayout $ do + setTitle "Administration: Medium Settings" $(widgetFile "adminMediumSet") Nothing -> do setMessage "This medium does not exist" diff --git a/Handler/AdminProfileSettings.hs b/Handler/AdminProfileSettings.hs index fcca07c..04432f4 100644 --- a/Handler/AdminProfileSettings.hs +++ b/Handler/AdminProfileSettings.hs @@ -16,6 +16,7 @@ getAdminProfilesR = do True -> do profiles <- runDB $ selectList [] [Desc UserName] defaultLayout $ do + setTitle "Administration: Profiles" $(widgetFile "adminProfiles") False -> do setMessage "You are no admin" @@ -38,6 +39,7 @@ getAdminUserAlbumsR ownerId = do Just owner -> do albums <- runDB $ selectList [AlbumOwner ==. ownerId] [Desc AlbumTitle] defaultLayout $ do + setTitle "Administration: User albums" $(widgetFile "adminUserAlbums") Nothing -> do setMessage "This user does not exist" @@ -63,6 +65,7 @@ getAdminUserMediaR ownerId = do Just owner -> do media <- runDB $ selectList [MediumOwner ==. ownerId] [Desc MediumTitle] defaultLayout $ do + setTitle "Administration: User media" $(widgetFile "adminUserMedia") Nothing -> do setMessage "This user does not exist" @@ -88,6 +91,7 @@ getAdminProfileSettingsR ownerId = do Just owner -> do (adminProfileSetWidget, enctype) <- generateFormPost $ adminProfileForm owner defaultLayout $ do + setTitle "Administration: Profile settings" $(widgetFile "adminProfileSettings") Nothing -> do setMessage "This user does not exist" diff --git a/Handler/Album.hs b/Handler/Album.hs index 85a0d02..44e9016 100644 --- a/Handler/Album.hs +++ b/Handler/Album.hs @@ -1,6 +1,7 @@ module Handler.Album where import Import +import qualified Data.Text as T getAlbumR :: AlbumId -> Handler Html getAlbumR albumId = do @@ -20,6 +21,7 @@ getAlbumR albumId = do -- media <- mapM (\a -> runDB $ getJust a) (albumContent album) media <- runDB $ selectList [MediumAlbum ==. albumId] [Desc MediumTime] defaultLayout $ do + setTitle $ toHtml ("Eidolon :: Album " `T.append` (albumTitle album)) $(widgetFile "album") Nothing -> do setMessage "This album does not exist" diff --git a/Handler/AlbumSettings.hs b/Handler/AlbumSettings.hs index 0ece880..b717c28 100644 --- a/Handler/AlbumSettings.hs +++ b/Handler/AlbumSettings.hs @@ -22,6 +22,7 @@ getAlbumSettingsR albumId = do True -> do (albumSettingsWidget, enctype) <- generateFormPost $ albumSettingsForm album albumId defaultLayout $ do + setTitle "Eidolon :: Album Settings" $(widgetFile "albumSettings") False -> do setMessage "You must own this album to change its settings" @@ -97,6 +98,7 @@ getAlbumDeleteR albumId = do case presence of True -> do defaultLayout $ do + setTitle $ toHtml ("Eidolon :: Delete album" `T.append` (albumTitle album)) $(widgetFile "albumDelete") False -> do setMessage "You must own this album to delete it" diff --git a/Handler/Home.hs b/Handler/Home.hs index 7b6cc1f..3db5db7 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -7,4 +7,5 @@ getHomeR :: Handler Html getHomeR = do recentMedia <- runDB $ selectList [] [Desc MediumTime] defaultLayout $ do + setTitle "Eidolon :: Home" $(widgetFile "home") diff --git a/Handler/Login.hs b/Handler/Login.hs index 961151d..efe7e92 100644 --- a/Handler/Login.hs +++ b/Handler/Login.hs @@ -20,6 +20,7 @@ getLoginR :: Handler Html getLoginR = do -- (loginWidget, enctype) <- generateFormPost loginForm defaultLayout $ do + setTitle "Eidolon :: Login" $(widgetFile "login") diff --git a/Handler/Medium.hs b/Handler/Medium.hs index 70a9585..a6fa909 100644 --- a/Handler/Medium.hs +++ b/Handler/Medium.hs @@ -2,6 +2,7 @@ module Handler.Medium where import Import import Data.Time +import qualified Data.Text as T import System.Locale getMediumR :: MediumId -> Handler Html @@ -22,6 +23,7 @@ getMediumR mediumId = do Nothing -> return False defaultLayout $ do + setTitle $ toHtml ("Eidolon :: Medium " `T.append` (mediumTitle medium)) $(widgetFile "medium") Nothing -> do setMessage "This image does not exist" diff --git a/Handler/MediumSettings.hs b/Handler/MediumSettings.hs index 14897a9..b3f98dd 100644 --- a/Handler/MediumSettings.hs +++ b/Handler/MediumSettings.hs @@ -21,6 +21,7 @@ getMediumSettingsR mediumId = do True -> do (mediumSettingsWidget, enctype) <- generateFormPost $ mediumSettingsForm medium defaultLayout $ do + setTitle "Eidolon :: Medium Settings" $(widgetFile "mediumSettings") False -> do setMessage "You must own this medium to change its settings" @@ -94,6 +95,7 @@ getMediumDeleteR mediumId = do case presence of True -> do defaultLayout $ do + setTitle "Eidolon :: Delete Medium" $(widgetFile "mediumDelete") False -> do setMessage "You must own this medium to delete it" diff --git a/Handler/NewAlbum.hs b/Handler/NewAlbum.hs index d2ca28e..22a446b 100644 --- a/Handler/NewAlbum.hs +++ b/Handler/NewAlbum.hs @@ -13,6 +13,7 @@ getNewAlbumR = do userId <- lift $ pure $ getUserIdFromText tempUserId (albumWidget, enctype) <- generateFormPost (albumForm userId) defaultLayout $ do + setTitle "Eidolon :: Create new Album" $(widgetFile "newAlbum") Nothing -> do setMessage "You need to be logged in" diff --git a/Handler/Profile.hs b/Handler/Profile.hs index 02197f0..66f7e1e 100644 --- a/Handler/Profile.hs +++ b/Handler/Profile.hs @@ -6,19 +6,25 @@ import qualified Data.Text as T getProfileR :: UserId -> Handler Html getProfileR ownerId = do - owner <- runDB $ get ownerId - ownerSlug <- lift $ pure $ userSlug $ fromJust owner - userAlbs <- runDB $ selectList [AlbumOwner ==. ownerId] [Asc AlbumTitle] - recentMedia <- (runDB $ selectList [MediumOwner ==. ownerId] [Desc MediumTime]) - msu <- lookupSession "userId" - presence <- case msu of - Just tempUserId -> do - userId <- lift $ pure $ getUserIdFromText tempUserId - return (userId == ownerId) - Nothing -> - return False - defaultLayout $ do - $(widgetFile "profile") + tempOwner <- runDB $ get ownerId + case tempOwner of + Just owner -> do + ownerSlug <- lift $ pure $ userSlug owner + userAlbs <- runDB $ selectList [AlbumOwner ==. ownerId] [Asc AlbumTitle] + recentMedia <- (runDB $ selectList [MediumOwner ==. ownerId] [Desc MediumTime]) + msu <- lookupSession "userId" + presence <- case msu of + Just tempUserId -> do + userId <- lift $ pure $ getUserIdFromText tempUserId + return (userId == ownerId) + Nothing -> + return False + defaultLayout $ do + setTitle $ toHtml ("Eidolon :: " `T.append` (userSlug owner) `T.append` "'s profile") + $(widgetFile "profile") + Nothing -> do + setMessage "This profile does not exist" + redirect $ HomeR getUserR :: Text -> Handler Html getUserR ownerName = do diff --git a/Handler/ProfileDelete.hs b/Handler/ProfileDelete.hs index a185088..52d0116 100644 --- a/Handler/ProfileDelete.hs +++ b/Handler/ProfileDelete.hs @@ -19,6 +19,7 @@ getProfileDeleteR userId = do case loginId == userId of True -> do defaultLayout $ do + setTitle "Eidolon :: Delete user profile" $(widgetFile "profileDelete") False -> do setMessage "You can only delete your own profile" diff --git a/Handler/ProfileSettings.hs b/Handler/ProfileSettings.hs index 55db4a5..4270850 100644 --- a/Handler/ProfileSettings.hs +++ b/Handler/ProfileSettings.hs @@ -16,6 +16,7 @@ getProfileSettingsR userId = do True -> do (profileSettingsWidget, enctype) <- generateFormPost $ profileSettingsForm user defaultLayout $ do + setTitle "Eidolon :: Profile settings" $(widgetFile "profileSettings") False -> do setMessage "You can only change your own profile settings" diff --git a/Handler/Reactivate.hs b/Handler/Reactivate.hs index 8ddd7ab..09738cd 100644 --- a/Handler/Reactivate.hs +++ b/Handler/Reactivate.hs @@ -8,6 +8,7 @@ getReactivateR :: Handler Html getReactivateR = do (reactivateWidget, enctype) <- generateFormPost reactivateForm defaultLayout $ do + setTitle "Eidolon :: Reactivate account" $(widgetFile "reactivate") postReactivateR :: Handler Html diff --git a/Handler/Signup.hs b/Handler/Signup.hs index 7dcc42e..60d2a4b 100644 --- a/Handler/Signup.hs +++ b/Handler/Signup.hs @@ -14,6 +14,7 @@ getSignupR :: Handler Html getSignupR = do -- (signupWidget, enctype) <- generateFormPost signupForm defaultLayout $ do + setTitle "Eidolon :: Signup" $(widgetFile "signup") postSignupR :: Handler Html diff --git a/Handler/Tag.hs b/Handler/Tag.hs index 0d0f7fb..fa34932 100644 --- a/Handler/Tag.hs +++ b/Handler/Tag.hs @@ -1,6 +1,7 @@ module Handler.Tag where import Import +import qualified Data.Text as T import Data.Maybe getTagR :: Text -> Handler Html @@ -13,4 +14,5 @@ getTagR tag = do ) tempMedia media <- return $ removeItem Nothing almostMedia defaultLayout $ do + setTitle $ toHtml ("Eidolon :: Tag " `T.append` tag) $(widgetFile "tagMedia") diff --git a/Handler/Upload.hs b/Handler/Upload.hs index 24bdb7b..dc4214c 100644 --- a/Handler/Upload.hs +++ b/Handler/Upload.hs @@ -2,7 +2,7 @@ module Handler.Upload where import Import as I import Data.Time -import Data.Text +import qualified Data.Text as T import System.FilePath data TempMedium = TempMedium @@ -23,6 +23,7 @@ getUploadR = do userId <- lift $ pure $ getUserIdFromText tempUserId (uploadWidget, enctype) <- generateFormPost (uploadForm userId) defaultLayout $ do + setTitle "Eidolon :: Upload Medium" $(widgetFile "upload") Nothing -> do setMessage "You need to be logged in" @@ -77,6 +78,7 @@ getDirectUploadR albumId = do True -> do (dUploadWidget, enctype) <- generateFormPost $ dUploadForm userId albumId defaultLayout $ do + setTitle $ toHtml ("Eidolon :: Upload medium to " `T.append` (albumTitle album)) $(widgetFile "dUpload") False -> do setMessage "You must own this album to upload" @@ -138,9 +140,9 @@ writeOnDrive :: FileInfo -> UserId -> AlbumId -> Handler FilePath writeOnDrive file userId albumId = do filename <- return $ fileName file path <- return $ "static" "data" - (unpack $ extractKey userId) - (unpack $ extractKey albumId) - (unpack filename) + (T.unpack $ extractKey userId) + (T.unpack $ extractKey albumId) + (T.unpack filename) liftIO $ fileMove file path return path