# HG changeset patch # User Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com> # Date 1447857545 -3600 # Node ID 03d2aa7b496734f548acdcb828b366e11ef4e73f # Parent e652022fd1f77e85c88f904055520e14cecf3b2f change default protocol diff -r e652022fd1f7 -r 03d2aa7b4967 script/utils/export_twitter_alchemy.py --- a/script/utils/export_twitter_alchemy.py Tue Nov 17 12:15:00 2015 +0100 +++ b/script/utils/export_twitter_alchemy.py Wed Nov 18 15:39:05 2015 +0100 @@ -44,7 +44,7 @@ get_logger().debug("re_fn : " + repr(expr) + "~" + repr(item)) #@UndefinedVariable return res is not None -def parse_polemics(tw, extended_mode): +def parse_polemics_1(tw, extended_mode): """ parse polemics in text and return a list of polemic code. None if not polemic found """ @@ -70,6 +70,37 @@ else: return None +def parse_polemics_2(tw, extended_mode): + """ + parse polemics in text and return a list of polemic code. None if not polemic found + """ + polemics = {} + for m in re.finditer("(\+\+|\!\!|\?\?|\=\=)",tw.text): + pol_link = { + '++' : u'OK', + '!!' : u'KO', + '??' : u'Q', + '==' : u'REF'}[m.group(1)] + polemics[pol_link] = pol_link + + if extended_mode: + if "?" in tw.text: + polemics["Q"] = "Q" + + for entity in tw.entity_list: + if entity.type == "entity_url": + polemics["REF"] = "REF" + + if len(polemics) > 0: + return polemics.keys() + else: + return None + +protocol_version_map = { + "1" : parse_polemics_1, + "2" : parse_polemics_2 +} + def get_options(): parser = argparse.ArgumentParser(description="All date should be given using iso8601 format. If no timezone is used, the date is considered as UTC") @@ -78,6 +109,9 @@ help="write export to file", metavar="FILE", default="project.ldt") parser.add_argument("-d", "--database", dest="database", help="Input database", metavar="DATABASE") + parser.add_argument("-a", "--annotation-protocol", dest="protocol_version", + help="annotation protocol version", metavar="PROTOCOL_VERSION", + default="2") parser.add_argument("-s", "--start-date", dest="start_date", help="start date", metavar="START_DATE", default=None) parser.add_argument("-e", "--end-date", dest="end_date", @@ -457,6 +491,7 @@ meta_element = etree.SubElement(element, u'meta') + parse_polemics = protocol_version_map.get(options.protocol_version, parse_polemics_2) polemics_list = parse_polemics(tw, options.extended_mode) if polemics_list: polemics_element = etree.Element(u'polemics') diff -r e652022fd1f7 -r 03d2aa7b4967 web/client.php --- a/web/client.php Tue Nov 17 12:15:00 2015 +0100 +++ b/web/client.php Wed Nov 18 15:39:05 2015 +0100 @@ -50,6 +50,8 @@ $_SESSION['TWITTER_REDIRECT_URL'] = isset($_REQUEST['auth_redirect']) ? $_REQUEST['auth_redirect'] : $_SERVER['HTTP_REFERER']; }; +$annotations = get_default_annotations_config($config, $translate); + ?> @@ -63,7 +65,7 @@ ' rel='stylesheet' type='text/css'> ' rel='stylesheet' type='text/css'> - + @@ -78,7 +80,7 @@ - + - + - + >
- +
- +
Intégrer @@ -332,7 +303,7 @@ - +
- + - +
@@ -490,13 +453,13 @@
- + - +

_('You must be connected with your Twitter account to read the conversation'); ?>

- + - +
_('config__pad_url');?> @@ -515,7 +478,7 @@
".$translate->_('config__partenaires').""); - + if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])){ echo("| ".$translate->_("Déconnexion").""); } diff -r e652022fd1f7 -r 03d2aa7b4967 web/common.php --- a/web/common.php Tue Nov 17 12:15:00 2015 +0100 +++ b/web/common.php Wed Nov 18 15:39:05 2015 +0100 @@ -17,7 +17,7 @@ $project_url_base = 'ldtplatform/ldt/cljson/id/'; -$C_default_rep = 'edito-1516-01-profil-collectif'; +$C_default_rep = 'museo-1516-01-inaugurale'; $C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0'; $C_event_props = __DIR__ . "/event_props"; $C_event_users = array('polemictweet' => 'polemictweet'.date('Y/m/d')); @@ -334,6 +334,143 @@ } +function get_default_annotations_config($config, $translate) { + + $default_protocol_annotations = array( + "1" => array( + "default" => array( + "colors" => array( + "h" => 0, + "s" => 0 + ) + ), + "positive" => array( + "display_name" => "++ | Agree", + "keywords" => "\\+\\+", + "colors" => array( + "h" => .3, + "s" => .65 + ), + "colors_class" => "twbGreen", + "polemic_cat" => 'OK', + "polemic_keywords" => array("++"), + "polemic_color" => "#1D973D" + ), + "negative" => array( + "display_name" => "-- | Disagree", + "keywords" => "\\-\\-", + "colors" => array( + "h" => 0, + "s" => .8 + ), + "colors_class" => "twbRed", + "polemic_cat" => 'KO', + "polemic_keywords" => array("--"), + "polemic_color" => "#CE0A15" + ), + "reference" => array( + "display_name" => "== | Reference", + "keywords" => "\\=\\=", + "colors" => array( + "h" => .16, + "s" => .8 + ), + "colors_class" => "twbYellow", + "polemic_cat" => 'REF', + "polemic_keywords" => array("==","http://"), + "polemic_color" => "#C5A62D" + ), + "question" => array( + "display_name" => "?? | Question", + "keywords" => "\\?\\?", + "colors" => array( + "h" => .6, + "s" => .8 + ), + "colors_class" => "twbBlue", + "polemic_cat" => 'Q', + "polemic_keywords" => array("?","??"), + "polemic_color" => "#036AAE" + ) + ), + "2" => array( + "default" => array( + "colors" => array( + "h" => 0, + "s" => 0 + ) + ), + "positive" => array( + "display_name" => "++ | Remember", + "keywords" => "\\+\\+", + "colors" => array( + "h" => .3, + "s" => .65 + ), + "colors_class" => "twbGreen", + "polemic_cat" => 'OK', + "polemic_keywords" => array("++"), + "polemic_color" => "#1D973D" + ), + "negative" => array( + "display_name" => "!! | Discuss", + "keywords" => "\\!\\!", + "colors" => array( + "h" => 0, + "s" => .8 + ), + "colors_class" => "twbRed", + "polemic_cat" => 'KO', + "polemic_keywords" => array("!!"), + "polemic_color" => "#CE0A15" + ), + "reference" => array( + "display_name" => "== | Reference", + "keywords" => "\\=\\=", + "colors" => array( + "h" => .16, + "s" => .8 + ), + "colors_class" => "twbYellow", + "polemic_cat" => 'REF', + "polemic_keywords" => array("==","http://"), + "polemic_color" => "#C5A62D" + ), + "question" => array( + "display_name" => "?? | Question", + "keywords" => "\\?\\?", + "colors" => array( + "h" => .6, + "s" => .8 + ), + "colors_class" => "twbBlue", + "polemic_cat" => 'Q', + "polemic_keywords" => array("?","??"), + "polemic_color" => "#036AAE" + ) + ) + ); + + $annotation_protocol_version = isset($config['annotation_protocol_version'])?$config['annotation_protocol_version']:"1"; + + $annotations_def = (isset($config['annotations']) && !empty($config['annotations']))?$config['annotations']:$default_protocol_annotations[$annotation_protocol_version]; + + $annotations = array(); + + foreach ($annotations_def as $annot_cat => $annot_def) { + if(isset($annot_def['display_name'])) { + $disp_parts = array_map('trim',explode("|",$annot_def['display_name'])); + if(count($disp_parts) > 1) { + $disp_parts[1] = $translate->_($disp_parts[1]); + } + $annot_def['display_name'] = implode(" | ", $disp_parts); + } + $annotations[$annot_cat] = $annot_def; + } + return $annotations; +} + + function get_archive_box($rep, $metadata, $url_root, $basepath, &$translate) { include("$basepath$rep/config.php"); @@ -429,6 +566,8 @@ global $realm; + $_SESSION['auth'] = 'polemictweet'; + return array('username'=>'polemictweet'); if (empty($_SERVER['PHP_AUTH_DIGEST']) || !isset($_SESSION['http_digest_nonce'])) { $_SESSION['http_digest_nonce'] = uniqid(); @@ -555,3 +694,50 @@ return strtolower($f); } + +function rgb2hex($rgb) { + $hex = "#"; + $hex .= str_pad(dechex($rgb[0]), 2, "0", STR_PAD_LEFT); + $hex .= str_pad(dechex($rgb[1]), 2, "0", STR_PAD_LEFT); + $hex .= str_pad(dechex($rgb[2]), 2, "0", STR_PAD_LEFT); + + return $hex; // returns the hex value including the number sign (#) +} + +function hsl2Rgb( $h, $s, $l ){ + $r; + $g; + $b; + $c = ( 1 - abs( 2 * $l - 1 ) ) * $s; + $x = $c * ( 1 - abs( fmod( ( $h / 60 ), 2 ) - 1 ) ); + $m = $l - ( $c / 2 ); + if ( $h < 60 ) { + $r = $c; + $g = $x; + $b = 0; + } else if ( $h < 120 ) { + $r = $x; + $g = $c; + $b = 0; + } else if ( $h < 180 ) { + $r = 0; + $g = $c; + $b = $x; + } else if ( $h < 240 ) { + $r = 0; + $g = $x; + $b = $c; + } else if ( $h < 300 ) { + $r = $x; + $g = 0; + $b = $c; + } else { + $r = $c; + $g = 0; + $b = $x; + } + $r = ( $r + $m ) * 255; + $g = ( $g + $m ) * 255; + $b = ( $b + $m ) * 255; + return array( floor( $r ), floor( $g ), floor( $b ) ); +} diff -r e652022fd1f7 -r 03d2aa7b4967 web/edito-1516-01-profil-collectif/config.php --- a/web/edito-1516-01-profil-collectif/config.php Tue Nov 17 12:15:00 2015 +0100 +++ b/web/edito-1516-01-profil-collectif/config.php Wed Nov 18 15:39:05 2015 +0100 @@ -25,4 +25,5 @@ 'slide_background' => 'images/slide_background.jpg', 'archive_img' => 'images/archive_img.jpg', 'metadata' => '', + 'annotation_protocol_version' => '2', ); diff -r e652022fd1f7 -r 03d2aa7b4967 web/event_form.php --- a/web/event_form.php Tue Nov 17 12:15:00 2015 +0100 +++ b/web/event_form.php Wed Nov 18 15:39:05 2015 +0100 @@ -14,7 +14,7 @@ ' rel='stylesheet' type='text/css'> ' rel='stylesheet' type='text/css'> - + @@ -66,8 +66,8 @@ } ?> - - + +