Add support for displaying new protocol V06.009
authorymh <ymh.work@gmail.com>
Mon, 22 Oct 2018 17:04:30 +0200
changeset 1480 d2d28468b410
parent 1479 2b510a3a0f7d
child 1481 f4c8af4e6060
Add support for displaying new protocol
script/utils/export_twitter_alchemy.py
web/marathon-serpentine-2018/config.php
web/player_embed.php
web/polemicaltimeline.php
--- a/script/utils/export_twitter_alchemy.py	Sun Sep 23 17:14:07 2018 +0200
+++ b/script/utils/export_twitter_alchemy.py	Mon Oct 22 17:04:30 2018 +0200
@@ -96,9 +96,34 @@
     else:
         return None
 
+def parse_polemics_3(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'REF',
+            '==' : u'Q'}[m.group(1)]
+        polemics[pol_link] = pol_link
+
+    if extended_mode:
+        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
+    "2" : parse_polemics_2,
+    "3" : parse_polemics_3
 }
 
 def get_options():
--- a/web/marathon-serpentine-2018/config.php	Sun Sep 23 17:14:07 2018 +0200
+++ b/web/marathon-serpentine-2018/config.php	Mon Oct 22 17:04:30 2018 +0200
@@ -160,7 +160,7 @@
     'additional_js' => ['reloader.php?a='.rand(),],
 
     // After the event
-    // 'metadata'		=> "fc62350e-69d9-11e1-9089-00145ea4a2be",
+    'metadata'		=> "cf54e97c-d146-11e8-8451-00145ea4a2be",
     // 'duration'  	=> 10876600,
     // 'player'        => "res/metadataplayer/src/js/LdtPlayer.js",
     // 'div_height'    => 740,
--- a/web/player_embed.php	Sun Sep 23 17:14:07 2018 +0200
+++ b/web/player_embed.php	Mon Oct 22 17:04:30 2018 +0200
@@ -35,7 +35,7 @@
     )
 );
 
-$protocol_level = min(3,max(0, $protocol_level));
+$protocol_level = min(4,max(0, $protocol_level));
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
@@ -78,7 +78,7 @@
 <?php if ($protocol_level > 1): ?>
             {
                 type: "Polemic"
-<?php if ($protocol_level < 3): ?>
+<?php if ($protocol_level < 4): ?>
                 ,
                 polemics: []
 <?php endif; ?>
--- a/web/polemicaltimeline.php	Sun Sep 23 17:14:07 2018 +0200
+++ b/web/polemicaltimeline.php	Mon Oct 22 17:04:30 2018 +0200
@@ -51,7 +51,7 @@
     array_push($_SESSION['answered_events'], $rep);
 }
 
-//$annotation_protocol_version = isset($config['annotation_protocol_version'])?$config['annotation_protocol_version']:"1";
+$annotation_protocol_version = isset($config['annotation_protocol_version'])?$config['annotation_protocol_version']:"1";
 $annotations = get_default_annotations_config($config, $translate);
 
 ?>
@@ -149,10 +149,9 @@
             {
                 type: "Polemic",
                 max_elements: 60,
-<?php if ($protocol_level < 4): ?>
-                polemics: []
-<?php elseif (isset($annotations)): ?>
-                polemics : [
+                default_version: "1",
+<?php if (isset($annotations)): ?>
+                polemics : { "<?php echo($annotation_protocol_version)?>":[
 <?php foreach ($annotations as $annot_key => $annot_def): ?>
     <?php 
     $hVal = (isset($annot_def['colors'])&&isset($annot_def['colors']['h']))?floatval($annot_def['colors']['h']):0.17;
@@ -168,7 +167,7 @@
                         "color" : "<?php echo $polemicColor; ?>"
                     },
 <?php endforeach; ?>
-                ]
+                ]}
 <?php endif; ?>
             },
 <?php endif; ?>