Created
June 19, 2016 06:31
-
-
Save opn/4cc35bc7818c0df1501f713c2d9384cd to your computer and use it in GitHub Desktop.
A set of tools for manipulating Fedwiki pages.
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
on index | |
put fedwiki_GetDroppedUrl ($_POST_RAW) into droppedURL | |
put fedwiki_ConstructErrorJSON (droppedURL &CR&CR& $_POST_RAW) into errorJSON | |
fedwiki_ReturnJSON errorJSON | |
end index | |
on fork_Cleaner | |
put fedwiki_GetDroppedUrl ($_POST_RAW) into droppedURL | |
put fedwiki_CleanLastLineUpJournal (droppedURL, "create,fork", "fedwiki-transport") into cleanJSON | |
fedwiki_ReturnJSON cleanJSON | |
end fork_Cleaner | |
on journal | |
put fedwiki_GetDroppedUrl ($_POST_RAW) into droppedURL | |
put fedwiki_CleanLastLineUpJournal (droppedURL) into cleanJSON | |
fedwiki_ReturnJSON cleanJSON | |
end journal | |
on clean_Title | |
put getPageArray ($_POST_RAW) into pageArray | |
-- | |
put pageArray ["Title"] into pageTitle | |
put text_InitialCaps (pageTitle) into pageTitle | |
put pageTitle into pageArray ["Title"] | |
-- | |
returnPageArray pageArray | |
end clean_Title | |
on fix_Title | |
put getPageArray ($_POST_RAW) into pageArray | |
-- | |
put pageArray ["Title"] into pageTitle | |
replace "-" with space in pageTitle | |
put word 1 to -1 of pageTitle into pageTitle | |
put text_InitialCaps (pageTitle) into pageTitle | |
put pageTitle into pageArray ["Title"] | |
-- | |
returnPageArray pageArray | |
end fix_Title | |
on clean_FirstLetter | |
put getPageArray ($_POST_RAW) into pageArray | |
-- | |
put pageArray ["Title"] into pageTitle | |
get toUpper (char 1 of pageTitle) | |
put it into char 1 of pageTitle | |
put pageTitle into pageArray ["Title"] | |
-- | |
returnPageArray pageArray | |
end clean_FirstLetter | |
command returnPageArray pageArray | |
put json_FromArray (pageArray) into pageJSON | |
fedwiki_ReturnJSON pageJSON | |
end returnPageArray | |
function getPageArray postJSON | |
put fedwiki_GetDroppedUrl (postJSON) into droppedURL | |
put fedwiki_FetchLastLineUpArray (droppedURL) into pageArray | |
if pageArray is false then | |
put merge ("The dropped url [[droppedURL]] is not a Fedwiki url.") into errorText | |
fedwiki_ExitAndReturnError errorText, "Not a Fedwiki URL" | |
end if | |
return pageArray | |
end getPageArray | |
function text_InitialCaps someText | |
repeat with wordNum = 1 to the number of words of someText | |
put tolower(word wordNum of someText) into someWord | |
put toupper(char 1 of someWord ) into char 1 of someWord | |
put someWord into word wordNum of someText | |
end repeat | |
return someText | |
end text_InitialCaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment