1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-29 16:48:33 +03:00

Guess whether new items are libraries or not

This commit is contained in:
Artyom 2016-03-13 20:21:50 +03:00
parent 63e808155e
commit 35561aaae8

View File

@ -189,7 +189,15 @@ addMethods = Spock.subcomponent "add" $ do
-- TODO: do something if the category doesn't exist (e.g. has been -- TODO: do something if the category doesn't exist (e.g. has been
-- already deleted) -- already deleted)
itemId <- randomUid itemId <- randomUid
newItem <- dbUpdate (AddItem catId itemId name' hackageLibrary) -- If the item name looks like a Hackage library, assume it's a Hackage
-- library.
--
-- TODO: a lot of things in the database are going to be marked as
-- “non-Hackage library” when in reality they aren't that it would have
-- to be fixed
newItem <- if T.all (\c -> isAscii c && (isAlphaNum c || c == '-')) name'
then dbUpdate (AddItem catId itemId name' hackageLibrary)
else dbUpdate (AddItem catId itemId name' Other)
category <- dbQuery (GetCategory catId) category <- dbQuery (GetCategory catId)
lucid $ renderItem category newItem lucid $ renderItem category newItem
-- Pro (argument in favor of a library) -- Pro (argument in favor of a library)
@ -469,9 +477,6 @@ helpVersion = 1
-- TODO: automatic merge should be possible too (e.g. if the changes are in -- TODO: automatic merge should be possible too (e.g. if the changes are in
-- different paragraphs) -- different paragraphs)
-- TODO: [easy] when adding a new item, don't make it a Hackage library if it
-- has spaces/punctuation in its name
-- TODO: [very-easy] rename selectChild to selectChildren -- TODO: [very-easy] rename selectChild to selectChildren
renderCategoryList :: [Category] -> HtmlT IO () renderCategoryList :: [Category] -> HtmlT IO ()
@ -970,6 +975,9 @@ thisNode = do
span_ [uid_ uid', class_ "dummy"] mempty span_ [uid_ uid', class_ "dummy"] mempty
return (selectParent (selectUid uid')) return (selectParent (selectUid uid'))
-- TODO: add an “ecosystem” field with related packages/etc (just a simple
-- Markdown-edited field under pros/cons)
-- Wheh changing these, also look at 'JS.switchSection'. -- Wheh changing these, also look at 'JS.switchSection'.
shown, noScriptShown :: Attribute shown, noScriptShown :: Attribute