Browse files

Added javascript to fill in wikiname on upload form automatically.

If noscript, print a message about leaving it blank for the default.
  • Loading branch information...
1 parent 3581759 commit 86d43a344554153580c2fa5180630172b2642287 @jgm committed Nov 8, 2008
Showing with 10 additions and 5 deletions.
  1. +6 −4 Gitit.hs
  2. +1 −1 gitit.cabal
  3. +3 −0 javascripts/uploadForm.js
View
10 Gitit.hs
@@ -158,7 +158,7 @@ initializeWiki repodir staticdir = do
zipWithM copyFile stylesheetpaths (map (staticdir </>) stylesheets)
createDirectoryIfMissing True $ staticdir </> "javascripts"
let javascripts = ["jquery.min.js", "jquery-ui-personalized-1.6rc2.min.js",
- "folding.js", "dragdiff.js", "preview.js", "search.js"]
+ "folding.js", "dragdiff.js", "preview.js", "search.js", "uploadForm.js"]
javascriptpaths <- mapM getDataFileName $ map ("javascripts" </>) javascripts
zipWithM copyFile javascriptpaths $ map ((staticdir </> "javascripts") </>) javascripts
hPutStrLn stderr $ "Created " ++ staticdir ++ " directory"
@@ -417,12 +417,14 @@ uploadForm _ params = do
let wikiname = pWikiname params `orIfNull` takeFileName origPath
let logMsg = pLogMsg params
let upForm = form ! [X.method "post", enctype "multipart/form-data"] <<
- [ p << [label << "File to upload:", br, afile "file" ! [value origPath]]
- , p << [label << "Name on wiki, including extension:", br, textfield "wikiname" ! [value wikiname],
+ [ p << [label << "File to upload:", br, afile "file" ! [value origPath] ]
+ , p << [label << "Name on wiki, including extension",
+ noscript << " (leave blank to use the same filename)", stringToHtml ":", br,
+ textfield "wikiname" ! [value wikiname],
primHtmlChar "nbsp", checkbox "overwrite" "yes", label << "Overwrite existing file"]
, p << [label << "Description of content or changes:", br, textfield "logMsg" ! [size "60", value logMsg],
submit "upload" "Upload"] ]
- formattedPage [HidePageControls] [] page params upForm
+ formattedPage [HidePageControls] ["uploadForm.js"] page params upForm
uploadFile :: String -> Params -> Web Response
uploadFile _ params = do
View
2 gitit.cabal
@@ -22,7 +22,7 @@ maintainer: jgm@berkeley.edu
data-files: stylesheets/gitit.css, stylesheets/hk-pyg.css,
stylesheets/folder.png, stylesheets/page.png,
javascripts/dragdiff.js, javascripts/folding.js,
- javascripts/jquery.min.js,
+ javascripts/jquery.min.js, javascripts/uploadForm.js,
javascripts/jquery-ui-personalized-1.6rc2.min.js,
javascripts/preview.js, javascripts/search.js,
data/post-update, data/FrontPage.page, data/Help.page,
View
3 javascripts/uploadForm.js
@@ -0,0 +1,3 @@
+$(document).ready(function(){
+ $("#file").change(function () { $("#wikiname").val($(this).val()); });
+ });

0 comments on commit 86d43a3

Please sign in to comment.