Browse Source

Add: Simple video element and improvements for list-view in rubble

Sebastian Kreisel 1 year ago
parent
commit
f8cc62e6a7

+ 12 - 10
TODO.txt

@@ -1,11 +1,13 @@
 -- Urgent
--------------------------------------------------------------------------------
-* Backend: Remove paging from rubble list view
+------------------------------------------------------------------------------
 * Backend: Polish list view in rubble (add selection etc)
+* Backend: Make consistent and decent rubble empty view
+* Frontend: Restrict ip loc requests to 300 per day via localstoreage
+* CSS+Parsing: Improve HTML5 video appearance
 
 
 -- Big picture, Summer update
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 * Backend: Instead of removing on "delete" change post type
 * CSS: Improve on h2 fontsize and styling
 * Files: Permissions on uploaded files
@@ -26,13 +28,13 @@
 * Misc: Backend: Decide if admin access is 5 or 10 and make consistent
 * Misc: Backend: In serveAdminSite use real access mod not magic 10
 * Misc: Backend: Make MathJax inclusion stricter
-* Misc: Git: Restructure doc/deploy/docker/config into seperated (private) repo
+* Misc: Git: Restructure doc/deploy/docker/config into seperated (prv) repo
 * Misc: Git: Improve README.txt
 * Misc: Think about and add a LICENSE
 
 
 -- Short Term
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 * Backend: Logout Page -> Back to Home if not logged in
 * Backend: svgs for image viewer
 * Frontend+Edit: /books paragraph merge but should not
@@ -43,7 +45,6 @@
 * Backend: Imageviewer: Support multiple contains
 * Backend: Imageviewer: Add excluding filtering
 * Backend: Add no-script tag to math posts
-* Backend+Admin: Modify log al-container to be width independent
 * Backend+CSS: Fix image view filename length
 * Backend: HTTP Header info for privacy: https://webbkoll.dataskydd.net/en
 * Backend: Think about compact combinator for ViewInfo
@@ -51,7 +52,7 @@
 
 
 -- Small/Vague and Low-priority
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 * Backend: Try to make site web-reader friendly
 * Backend: Try to make edit interface more mobile-friendly
 * Frontend: Stop automatic safe if POST failes twice and start again
@@ -61,14 +62,13 @@
 
 
 -- Longterm/Infrastructure
--------------------------------------------------------------------------------
+------------------------------------------------------------------------------
 * Look into caching and better CSS delivery
 * Latex math via nodejs
 
 
 -- Housekeeping
--------------------------------------------------------------------------------
-
+------------------------------------------------------------------------------
 * Backend: Clean up new ip-location related code in model and endpoint
 * Backend: Check on the mess that is image (directory) serving
 * Backend: Edit Endpoint: Fetch Access Magic Number 10
@@ -91,3 +91,5 @@
 * Frontend Edit: Clean up validation / information in files frontend
 * Front+Backend: Move input sani to bkend i.e. whitespace with title etc
 * Static: Simplify CSS and summarize where possible
+
+

+ 8 - 3
elfcom-backend/src/Main.hs

@@ -218,16 +218,21 @@ getDrivel mu = do
   st <- getState
   rndE <- liftIO $ getRandomElf st 20
   let v = dockerVersion st
+  let dsPage = if viewmode == "list" then 0 else currPage
+  let dsLastPage = if viewmode == "list" then 0 else max 0 (pageCount - 1)
   let dstate = DrivelState
                { currentTime = now
-               , currentPage = currPage
-               , lastPage = max 0 (pageCount - 1)
+               , currentPage = dsPage
+               , lastPage = dsLastPage
                , allCategories = allCats
                , selectedCategories = selCats
                , ptypes = ptypes
                , daccess = daccess
                , viewMode = viewmode
                , rndElf = rndE}
+  let prange = if viewmode == "list"
+                  then Nothing
+                  else Just (currPage * ppp, (currPage + 1) * ppp - 1)
   let pquery = PostQuery
                { access = acc
                , postTypes = ptypes
@@ -235,7 +240,7 @@ getDrivel mu = do
                , cats = selCats
                , title = Nothing
                , drange = Nothing
-               , prange = Just (currPage * ppp, (currPage + 1) * ppp - 1) }
+               , prange = prange }
   posts <- runSQL $ queryPostList pquery
   blaze $ drivelSite (ViewInfo "/rubble" rndE v mu) posts dstate
   where foo [""] = []

+ 19 - 15
elfcom-backend/src/View/Drivel.hs

@@ -67,17 +67,17 @@ drivelRight dst acc = do
       "Select filters. Active filters are " >> b "bold" >> "."
     div ! class_ "drivel-right-descr" $ "Content"
     div ! class_ "drivel-cat-cnt" $
-      a ! href (textValue $ makeContHref cp selcats (togglePT 1 ptyps) dacc) !
+      a ! href (textValue $ makeContHref (togglePT 1 ptyps) dst) !
       class_ (textValue $ T.append "drivel-link " (foo (ptyps == [1]))) $
       "Only Posts"
     div ! class_ "drivel-cat-cnt" $
-      a ! href (textValue $ makeContHref cp selcats (togglePT 2 ptyps) dacc) !
+      a ! href (textValue $ makeContHref (togglePT 2 ptyps) dst) !
         class_ (textValue $ T.append "drivel-link " (foo (ptyps == [2]))) $
         "Only Rubble"
     case acc of
       x | x >= 1 -> do
         div ! class_ "drivel-cat-cnt" $
-          a!href (textValue$makeContHref cp selcats (togglePT 3 ptyps) dacc) !
+          a!href (textValue $makeContHref (togglePT 3 ptyps) dst) !
           class_ (textValue $T.append "drivel-link " (foo (ptyps == [3]))) $
           "Only Internal"
       _ -> return ()
@@ -115,27 +115,27 @@ togglePT x xs | xs == [x] = [1,2]
               | otherwise = [x]
 
 makeCatHref :: T.Text -> Bool -> DrivelState -> T.Text
-makeCatHref cat isSel (DrivelState _ cp _ _ selcats ptyps dacc _ _) =
+makeCatHref cat isSel (DrivelState _ cp _ _ selcats ptyps dacc vm _) =
   T.append "/rubble" (makeDrivelGetArgs cp
                       (textToMaybe $ T.intercalate "," (modSel (not isSel)))
-                      ptyps dacc)
+                      ptyps dacc vm)
   where modSel True = cat : selcats
         modSel False = delete cat selcats
 
 makeAccHref :: Int -> DrivelState -> T.Text
-makeAccHref selacc (DrivelState _ cp _ _ selcats ptyps dacc _ _) =
+makeAccHref selacc (DrivelState _ cp _ _ selcats ptyps dacc vm _) =
   T.append "/rubble" (makeDrivelGetArgs cp
                       (textToMaybe $ T.intercalate "," selcats)
-                      ptyps (compacc dacc selacc))
+                      ptyps (compacc dacc selacc) vm)
   where compacc Nothing s = Just s
         compacc (Just d) s | d == s = Nothing
                            | otherwise = Just s
 
-makeContHref :: Int -> [T.Text] -> [Int] -> Maybe Int -> T.Text
-makeContHref cp selcats ptyps acc =
+makeContHref :: [Int] -> DrivelState -> T.Text
+makeContHref ptyps (DrivelState _ cp _ _ selcats _ dacc vm _) =
   T.append "/rubble" (makeDrivelGetArgs cp
                       (textToMaybe $ T.intercalate "," selcats)
-                      ptyps acc)
+                      ptyps dacc vm)
 
 -- Middle
 -- -------------------------------------------------------------------------
@@ -257,10 +257,10 @@ drivelPage dst = do
                   | otherwise = " drivel-nav-link-unsel"
 
 makePageHref :: Int -> DrivelState -> T.Text
-makePageHref pth (DrivelState _ _ _ _ cats ptyps acc _ _) =
+makePageHref pth (DrivelState _ _ _ _ cats ptyps acc vm _) =
   T.append "/rubble" (makeDrivelGetArgs pth
                       (textToMaybe $ T.intercalate "," cats)
-                      ptyps acc)
+                      ptyps acc vm)
 
 balanceP :: [Int] -> Int -> Int -> Int -> (Int, Int) -> Int -> [Int]
 balanceP acc curr minn maxx offs l
@@ -287,16 +287,20 @@ balanceP acc curr minn maxx offs l
 -- -------------------------------------------------------------------------
 
 -- Ugly sig for direct GET parameters
-makeDrivelGetArgs :: Int -> Maybe T.Text -> [Int] -> Maybe Int -> T.Text
-makeDrivelGetArgs page mcats ptypes macc =
+makeDrivelGetArgs :: Int -> Maybe T.Text -> [Int] -> Maybe Int ->
+                     T.Text -> T.Text
+makeDrivelGetArgs page mcats ptypes macc viewmode =
   let bar f arg = fromMaybe [] (fmap f arg)
   in makeGetParams (bar (\c -> [("p", T.pack $ show c)]) (ptm page) ++
                     bar (\c -> [("categories", c)]) mcats ++
                     bar (\c -> [("ptypes",
                                  T.intercalate "+" (map (T.pack . show) c))])
                     (ltm ptypes) ++
-                    bar (\c -> [("access", T.pack $ show c)]) macc)
+                    bar (\c -> [("access", T.pack $ show c)]) macc ++
+                    bar (\c -> [("view", c)]) (mtm viewmode))
   where ltm xs | sort xs == [1,2] = Nothing -- default setting, hide GET par
                | otherwise = Just xs
         ptm 0 = Nothing
         ptm p = Just p
+        mtm "default" = Nothing
+        mtm vm = Just vm

+ 7 - 7
elfcom-backend/src/View/Edit.hs

@@ -84,7 +84,7 @@ s1 = [ ("c = 1", "norm")
      , ("width", "758")
      , ("mini-2", "374 :: 10")
      , ("mini-3", "248 :: 7")
-     ]
+     , ("mini-r", "275 :: 10") ]
 
 s2 :: [(String, String)]
 s2 = [ ("frac", "a")
@@ -106,10 +106,10 @@ s3 = [ ("big", "i")
      , ("Big", "o")
      , ("bigg", "p")
      , ("", "")
-     , ("L R Arrow", "r")
-     , ("L L Arrow", "t")
-     , ("L LR Arrow", "z")
-     , ("S R Arrow", "u")
+     , ("stackrel", "r")
+     , ("text", "t")
+     , ("longright Arrow", "z")
+     , ("Longright Arrow", "u")
      ]
 
 s4 :: [(String, String)]
@@ -124,5 +124,5 @@ s4 = [ ("inline math", "y")
      , ("env", "1")
      , ("itemize", "2")
      , ("enumerate", "3")
-     , ("minipage", "4")
-     , ("center", "5") ]
+     , ("mini-2", "4")
+     , ("mini-r", "5") ]

+ 6 - 0
elfcom-backend/static/css/latex.css

@@ -57,6 +57,12 @@ img.txt-img {
     margin: 0 auto;
 }
 
+video.txt-video {
+  display: block;
+  width: 100%;
+  height: 100%;
+}
+
 a.txt-img-link {
     display: block;
 }

+ 6 - 5
elfcom-frontend/edit/site_edit.js

@@ -136,10 +136,11 @@ var shortcuts = {
   "79": ["\\Big\\Big", -4], // o
   "80": ["\\bigg\\bigg", -5], // p
 
-  "82": ["~\\Longrightarrow~", 0], // r
-  "84": ["~\\Longleftarrow~", 0], // t
-  "90": ["~\\Longleftrightarrow~", 0], // z
-  "85": ["~\\mathrel{\\rlap{\\hskip .5em/}}\\Longrightarrow~", 0], // u
+  "82": ["\\stackrel{}{}", -3], // r
+  "84": ["~\\text{}", -1], // t
+  "90": ["~\\longrightarrow~", 0], // z
+  "85": ["~\\Longrightarrow~", 0], // u
+  "73": ["~\\mathrel{\\rlap{\\hskip .5em/}}\\Longrightarrow~", 0], // i
 
   // general
   "89": ["\\(  \\)", -3], // y
@@ -154,6 +155,6 @@ var shortcuts = {
   "49": ["\\begin{}\n\n\\end{}", -9], // 1
   "50": ["\\begin{itemize}\n\\item \n\\end{itemize}\n", -15], // 2
   "51": ["\\begin{enumerate}\n\\item \n\\end{enumerate}\n", -17], // 3
-  "52": ["\\begin{minipage}[t]{375px}\n\n\\end{minipage}\n", -16], // 4
+  "52": ["\\begin{minipage}[t]{374px}\n\n\\end{minipage}\n", -16], // 4
   "53": ["\\begin{center}\n\n\\end{center}\n", -14], // 5
 };