diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-01-21 13:32:53 -0500 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-02-13 13:29:34 -0500 |
commit | 8ec4511374408b69bca34b0cf1a9afb9fbedd66e (patch) | |
tree | f34122a5d37c21354753922b5ba265fec337c083 | |
parent | cbaf04e367ff3fd05b5f8973e55aef90c4debf5f (diff) |
stash categories
-rw-r--r-- | post_fsd_wiki.phantomjs | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/post_fsd_wiki.phantomjs b/post_fsd_wiki.phantomjs index 688a65a..6ea6433 100644 --- a/post_fsd_wiki.phantomjs +++ b/post_fsd_wiki.phantomjs @@ -1,3 +1,14 @@ +/*\ post_fsd_wiki.phantomjs +|*| +|*| this script is used to create/modify mediawiki pages on the FSD +|*| +|*| one such wiki page for each blacklisted package +|*| +|*| it must be executed by the phantomjs program +|*| and have access to a JSON file as created by the report.rb script +\*/ + + var BLACKLIST_DATA_FILE = './blacklist-testdata.json' ; var WIKI_TEMPLATE_FILE = './wiki-template.json' ; var WIKI_BASE_URL = 'http://localhost/mediawiki/index.php' ; @@ -25,6 +36,15 @@ var REFERENCE_KEY = 'ref' ; // BLACKLIST_DATA_FILE JSON pe var ENTRY_ID_KEY = 'id' ; // BLACKLIST_DATA_FILE JSON per ./SYNTAX CSV[3] var DESCRIPTION_KEY = 'short_description' ; // BLACKLIST_DATA_FILE JSON per ./SYNTAX CSV[4] var BLACKLIST_TAGS_KEY = 'blacklist_tags' // BLACKLIST_DATA_FILE JSON +var NONFREE_TAG = 'nonfree' ; +var SEMIFREE_TAG = 'semifree' ; +var USES_NONFREE_TAG = 'uses-nonfree' ; +var BRANDING_TAG = 'branding' ; +var TECHNICAL_TAG = 'technical' ; +var HAS_REPLACEMENT_TAG = 'FIXME:package' ; +var NEEDS_DESC_TAG = 'FIXME:description' ; +var ACCEPTED_TAGS = [ NONFREE_TAG , SEMIFREE_TAG , USES_NONFREE_TAG , + HAS_REPLACEMENT_TAG , NEEDS_DESC_TAG ] ; var STEP_FUNCTION_KEY = 'step-function' ; var PAGELOAD_WAIT_KEY = 'wait-for-pageload' ; var STEP_TIMEOUT = 3000 ; var StepTimeout ; @@ -60,7 +80,7 @@ function Prepare() var package_name = package_data[PACKAGE_NAME_KEY ] && package_data[PACKAGE_NAME_KEY ].trim() ; var replacement = package_data[REPLACEMENT_KEY ] && package_data[REPLACEMENT_KEY ].trim() ; var description = package_data[DESCRIPTION_KEY ] && package_data[DESCRIPTION_KEY ].trim() ; - var blacklist_tags = package_data[BLACKLIST_TAGS_KEY] && package_data[BLACKLIST_TAGS_KEY] ; + var blacklist_tags = package_data[BLACKLIST_TAGS_KEY] ; if ((!IsA(package_name , String) ) || (!IsA(replacement , String) && replacement != '') || @@ -68,11 +88,17 @@ function Prepare() (!IsA(blacklist_tags , Array ) ) ) { LOG_ERR("invalid package data - ignoring:\n" + JSON.stringify(package_data)) ; return ; } + package_name = package_name.toLowerCase().replace(/ /g , '_') ; + var replacement_text = (!!replacement) ? '*Parabola Replacement: ' + replacement + '\n\n' : '' ; + blacklist_tags = blacklist_tags.filter(function(tag) { return ~ACCEPTED_TAGS.indexOf(tag) ; }) + .map (function(tag) { return 'FSDG_' + tag }) ; + if (blacklist_tags.length == 0) { LOG(package_name + " tags are uninteresting - ignoring") ; return ; } + LOG("loading package data: " + package_name) ; var wiki_page = {} ; - wiki_page[PACKAGE_NAME_KEY ] = package_name.toLowerCase().replace(/ /g , '_') ; - wiki_page[REPLACEMENT_KEY ] = (!!replacement) ? '*Parabola Replacement: ' + replacement + '\n\n' : '' ; + wiki_page[PACKAGE_NAME_KEY ] = package_name ; + wiki_page[REPLACEMENT_KEY ] = replacement_text wiki_page[DESCRIPTION_KEY ] = description ; wiki_page[BLACKLIST_TAGS_KEY] = blacklist_tags ; WikiPages.push(wiki_page) ; @@ -198,7 +224,8 @@ function VerifyEdit() page_title = page_title.replace(/_/g , ' ') ; wiki_text = PARABOLA_ENTRY_HEADER.replace(/=/g , '').trim() + '\n' + replacement_text .replace(/\*/g , '').trim() + '\n' + wiki_text ; - var categories_text = 'Categories: ' + wiki_categories.join('') ; + var categories = wiki_categories.join('').replace(/_/g , ' ') ; + var categories_text = ((wiki_categories.length > 1) ? 'Categories: ' : 'Category: ') + categories ; if (DEBUG_VB) DUMPFILE() ; @@ -327,7 +354,7 @@ Page.onUrlChanged = function() { LOG_ARGS.apply("Page.onUrlC Page.onConsoleMessage = function(msg) { DBG('')(msg) ; } ; -var DEBUG = false ; var DEBUG_EVS = DEBUG && false ; var DEBUG_VB = DEBUG && false ; +var DEBUG = true ; var DEBUG_EVS = DEBUG && false ; var DEBUG_VB = DEBUG && false ; function LOG (log , color) { console.log((color || '\033[00;32m') + log + '\033[00m' ) ; } function LOG_STEP(name) { LOG("Step: " + name , '\033[01;32m') ; } function LOG_ERR (err) { LOG("ERROR: " + err , '\033[00;31m') ; } @@ -353,11 +380,11 @@ function DBG(context) Dbg("SubmitEdit() modified_wiki_text=" + modified_wiki_text ) ; Dbg("SubmitEdit() post_wiki_text=" + post_wiki_text ) ; Dbg("SubmitEdit() (modified_wiki_text == existing_wiki_text)=" + (modified_wiki_text == existing_wiki_text)) ; - Dbg("SubmitEdit() wiki_text_regex.test(existing_wiki_text)=" + wiki_text_regex.test(existing_wiki_text) ) ; } + Dbg("SubmitEdit() wiki_text_regex.test(existing_wiki_text )=" + wiki_text_regex.test(existing_wiki_text) ) ; } function DbgSubmitEditOut(post_wiki_text) { if (DEBUG_VB) Dbg("SubmitEdit() returned post_wiki_text=" + post_wiki_text) ; } function DbgVerifyEdit(wiki_title_h1 , wiki_text_div , categories_div , existing_wiki_title , page_title , existing_wiki_text , new_wiki_text , existing_categories , new_categories , wiki_text_regex , categories_regex) - { Dbg("VerifyEdit() wiki_title_h1=" + wiki_title_h1 + " wiki_title_h1.nodeName=" + wiki_title_h1.nodeName ) ; - Dbg("VerifyEdit() wiki_text_div=" + wiki_text_div + " wiki_text_div.nodeName=" + wiki_text_div.nodeName ) ; + { Dbg("VerifyEdit() wiki_title_h1=" + wiki_title_h1 + " wiki_title_h1 .nodeName=" + wiki_title_h1.nodeName ) ; + Dbg("VerifyEdit() wiki_text_div=" + wiki_text_div + " wiki_text_div .nodeName=" + wiki_text_div.nodeName ) ; Dbg("VerifyEdit() categories_div=" + categories_div + " categories_div.nodeName=" + categories_div.nodeName) ; Dbg("VerifyEdit() existing_wiki_title=" + existing_wiki_title ) ; Dbg("VerifyEdit() page_title=" + page_title ) ; @@ -365,8 +392,8 @@ function DBG(context) Dbg("VerifyEdit() new_wiki_text=" + new_wiki_text ) ; Dbg("VerifyEdit() existing_categories=" + existing_categories ) ; Dbg("VerifyEdit() new_categories=" + new_categories ) ; - Dbg("VerifyEdit() (existing_wiki_title == page_title )=" + (existing_wiki_title == page_title) ) ; - Dbg("VerifyEdit() wiki_text_regex .test(existing_wiki_text)=" + wiki_text_regex .test(existing_wiki_text) ) ; + Dbg("VerifyEdit() (existing_wiki_title == page_title )=" + (existing_wiki_title == page_title) ) ; + Dbg("VerifyEdit() wiki_text_regex .test(existing_wiki_text )=" + wiki_text_regex .test(existing_wiki_text) ) ; Dbg("VerifyEdit() categories_regex.test(existing_categories)=" + categories_regex.test(existing_categories) ) ; } function DbgMainLoop() { if (DEBUG_VB) Dbg("MainLoop() ShouldQuit=" + ShouldQuit + " IsReady=" + IsReady) ; } function DbgGetUrl(get_url) { Dbg("GetUrl() " + get_url) ; } |