Merge with 9f24acbe66fb87308778a41a18d19bb918bdb50f
authorYves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Tue, 09 Aug 2011 13:07:23 +0200
changeset 253 e9335ee3cf71
parent 252 2ebf22c65168 (diff)
parent 245 4c953ca2aa1d (current diff)
child 254 2209e66bb50b
Merge with 9f24acbe66fb87308778a41a18d19bb918bdb50f
script/lib/iri_tweet/models.py
script/lib/iri_tweet/utils.py
--- a/script/lib/iri_tweet/models.py	Tue Aug 09 12:41:37 2011 +0200
+++ b/script/lib/iri_tweet/models.py	Tue Aug 09 13:07:23 2011 +0200
@@ -151,15 +151,13 @@
     profile_text_color= Column(String)
     profile_use_background_image= Column(Boolean)
     protected= Column(Boolean)
-    screen_name= Column(String)
+    screen_name= Column(String, index=True, unique=True)
     show_all_inline_media= Column(Boolean)
     statuses_count = Column(Integer)
     time_zone= Column(String)
     url= Column(String)
     utc_offset = Column(Integer)
     verified= Column(Boolean)
-    #tweets = relationship(Tweet, backref='user')
-    #messages  = relationship(UserMessage, backref='user')
 
     def __init__(self, **kwargs):
         for key, value in kwargs.items():
@@ -170,7 +168,7 @@
 class Hashtag(Base):
     __tablename__ = "tweet_hashtag"
     id = Column(Integer, primary_key=True)
-    text = Column(String, unique = True)
+    text = Column(String, unique = True, index = True)
     def __init__(self, **kwargs):
         for key, value in kwargs.items():
             if hasattr(self,key):
@@ -231,7 +229,7 @@
                 
 def setup_database(*args, **kwargs):
         
-    create_all = True        
+    create_all = True
     if "create_all" in kwargs:
         create_all = kwargs["create_all"]
         del(kwargs["create_all"])
--- a/script/lib/iri_tweet/utils.py	Tue Aug 09 12:41:37 2011 +0200
+++ b/script/lib/iri_tweet/utils.py	Tue Aug 09 13:07:23 2011 +0200
@@ -184,7 +184,7 @@
         if user_id:
             user_obj = self.session.query(User).filter(User.id == user_id).first()
         else:
-            user_obj = self.session.query(User).filter(User.screen_name == user_name).first()
+            user_obj = self.session.query(User).filter(User.screen_name.ilike(user_name)).first()
     
         if user_obj is not None:
             user = ObjectBufferProxy(User, None, None, False, user_obj)
@@ -203,11 +203,18 @@
             except Exception as e:
                 logger.info("get_user : TWITTER ERROR : " + repr(e)) #@UndefinedVariable
                 logger.info("get_user : TWITTER ERROR : " + str(e)) #@UndefinedVariable
+                return None
     
         user_dict = adapt_fields(user_dict, fields_adapter["stream"]["user"])
         if "id" not in user_dict:
             return None
         
+        #TODO filter get, wrap in proxy
+        user = self.session.query(User).filter(User.id == user_dict["id"]).first()
+        
+        if user is not None:
+            return user
+        
         user = self.obj_buffer.add_object(User, None, user_dict, True)
         
         return user
@@ -230,11 +237,11 @@
                 return None
             hashtag = self.obj_buffer.get(Hashtag, text=text)
             if hashtag is None: 
-                hashtag_obj = self.session.query(Hashtag).filter(Hashtag.text == text).first()
+                hashtag_obj = self.session.query(Hashtag).filter(Hashtag.text.ilike(text)).first()
                 if hashtag_obj is not None:
                     hashtag = ObjectBufferProxy(Hashtag, None, None, False, hashtag_obj)
                     
-            if not hashtag:
+            if hashtag is None:
                 ind["text"] = text
                 hashtag = self.obj_buffer.add_object(Hashtag, None, ind, True)
             entity_dict['hashtag_id'] = hashtag.id
@@ -293,9 +300,23 @@
         self.tweet = self.obj_buffer.add_object(Tweet, None, ts_copy, True)
             
         # get entities
-        for ind_type, entity_list in self.json_dict["entities"].items():
-            for ind in entity_list:
-                self.__process_entity(ind, ind_type)
+        if "entities" in self.json_dict:
+            for ind_type, entity_list in self.json_dict["entities"].items():
+                for ind in entity_list:
+                    self.__process_entity(ind, ind_type)
+        else:
+            extractor = twitter_text.Extractor(self.tweet.text)
+    
+            for ind in extractor.extract_hashtags_with_indices():
+                self.__process_entity(ind, "hashtags")
+    
+            for ind in extractor.extract_mentioned_screen_names_with_indices():
+                self.__process_entity(ind, "user_mentions")
+    
+            for ind in extractor.extract_urls_with_indices():
+                self.__process_entity(ind, "urls")
+
+        self.session.flush()
 
 
     def __process_twitter_rest(self):
@@ -330,7 +351,6 @@
         user = self.__get_user(user_fields)
         if user is None:
             logger.warning("USER not found " + repr(user_fields)) #@UndefinedVariable
-            tweet_fields["user"] = None
             tweet_fields["user_id"] = None
         else:
             tweet_fields["user_id"] = user.id
--- a/web/about.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/about.php	Tue Aug 09 13:07:23 2011 +0200
@@ -45,6 +45,7 @@
 	</script>
   </head>
   <body>
+	<div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
     <div class="container">
      <a href="index.php">  <img src="images/ENMI_2010_logo.gif" class="logo"></a>
 	  <ul class="menu"> 
--- a/web/archives.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/archives.php	Tue Aug 09 13:07:23 2011 +0200
@@ -54,6 +54,7 @@
 	</script>
   </head>
   <body>
+	<div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
     <div class="container">
       <img src="images/ENMI_2010_logo.gif" class="logo">
 	  <ul class="menu"> 
--- a/web/client.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/client.php	Tue Aug 09 13:07:23 2011 +0200
@@ -235,6 +235,7 @@
 	
   </head>
   <body>
+	<div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
     <div class="container">
       <img src="<?php echo($head_logo); ?>" class="Producteur logo">
       <div id="minilogo" style="margin-left:85px;height:5px;top:5px;"></div>
--- a/web/common.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/common.php	Tue Aug 09 13:07:23 2011 +0200
@@ -14,6 +14,7 @@
 * Base configuration
 */
 $C_default_rep = 'sig-chi-paris-2011';
+$C_feedback_form_url = 'https://spreadsheets.google.com/spreadsheet/viewform?hl=en_US&formkey=dDZILVdXVHRzd0xhWGVZXzkweHN2RGc6MQ#gid=0';
 
 $configuration = array(
     'siteUrl'        => 'http://twitter.com/oauth',
@@ -170,8 +171,9 @@
 
 $archives_list = array(
     "rsln", "rsln-opendata", "rsln-mercedes-bunz",
-	"enmi2011-technologie-confiance", "CPV", "fens_FabLab_Design_Metadata",
-	array("mashup","conference"), array("mashup","tableronde"), "sig-chi-paris-2011"
+	"enmi2011-technologie-confiance", "CPV", array("fens_FabLab_Design_Metadata","fablab"),
+	array("fens_FabLab_Design_Metadata","designmd"), array("mashup","conference"), array("mashup","tableronde"),
+	"sig-chi-paris-2011",
 );
 
 function registry_url($key, $type, $registry_def=null) {
--- a/web/fens_FabLab_Design_Metadata/config.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/fens_FabLab_Design_Metadata/config.php	Tue Aug 09 13:07:23 2011 +0200
@@ -1,10 +1,5 @@
 <?php
 
-/**
- * FAKE ONE 
- * Please edit the conférence details 
- * 
- */
 $config = array(    
     'hashtag'    => '#fens',
     'date'   	 => '21.06.2011',
@@ -12,7 +7,7 @@
     'place'   	 => 'IRI - Salle Piazza - Centre Pompidou',
     'duration'   => '5628200',
     
-    'title' 	 => "Futur en Sine : Design Metadata",
+    'title' 	 => "Futur en Seine : Design Metadata",
 	'abstract'   => '',
     'description'=> "Cette conférence coordonnée par l’Institut de Recherche et d’innovation du Centre Pompidou a présenté les travaux réalisés lors de deux ateliers, un avec les étudiants de l’ENSCI sur les interfaces de production de méta données et un avec Strate Collège et l’ESILV sur l’utilisation d’interface sans contact dans l’espace urbain. Ces ateliers ont eu pour but d’accompagner concrètement le maquettage et le prototypage des projets des élèves en mettant en place une méthodologie d’open innovation dans un contexte interdisciplinaire.",
 					
@@ -26,15 +21,21 @@
 		 |  <a href='http://www.stratecollege.fr/' class='footerLink' target='_blank'> Strate Collège </a>",
 		 
 	// After the event 
-	'metadata'	 => "http://www.iri.centrepompidou.fr/dev/ldt/ldtplatform/ldt/cljson/id/69e7b3e4-a8ae-11e0-85c5-00145ea49a02",
+	'metadata'	 => array(
+		'fablab'=>array('url'=>"http://www.iri.centrepompidou.fr/dev/ldt/ldtplatform/ldt/cljson/id/de9e77c2-b33a-11e0-8465-00145ea49a02", 'display'=> 'Fab Lab', 'duration'=>'12177600'),
+		'designmd'=>array('url'=>"http://www.iri.centrepompidou.fr/dev/ldt/ldtplatform/ldt/cljson/id/69e7b3e4-a8ae-11e0-85c5-00145ea49a02", 'display'=> 'Design Metadata', 'duration'=>'5628258'),
+	),
     'player'     => "res/metadataplayer/src/js/LdtPlayer.js",
 
 	'client_visual' => 'images/big_visuel_rsln_mb.jpg', // optional - relative path
    	'head_logo' => 'images/head_logo.gif', // optional - relative path
 	'slide_background' => 'images/slide4.jpg',
-	'archive_img' => 'images/tail_fens_fablab_designmd.jpg',
-	'archive_title' => "DESIGN METADATA",
-	'archive_description' => 'par <a href="http://www.iri.centrepompidou.fr" target="_blank">IRI</a> au Centre Pompidou<br/>le mardi 21 juin 2011 | 17:00 - 20:00',
+	'archive_img' => array('designmd'=>'images/tail_fens_fablab_designmd.jpg', 'fablab'=>'images/tail_fens_fablab_fablab.jpg'),
+	'archive_title' => array('designmd'=> "Futur en Seine : Design Metadata", 'fablab'=>"Futur en Seine : Fablab"),
+	'archive_description' => array(
+		'designmd'=>'par <a href="http://www.iri.centrepompidou.fr" target="_blank">IRI</a> au Centre Pompidou<br/>le mardi 21 juin 2011 | 17:00 - 20:00',
+		'fablab'=>'par <a href="http://www.iri.centrepompidou.fr" target="_blank">IRI</a> au Centre Pompidou<br/>le mardi 20 juin 2011 | 17:00 - 20:00',
+	),
 	
 	
 	'div_height' => 750,
Binary file web/fens_FabLab_Design_Metadata/images/tail_fens_fablab_designmd.jpg has changed
Binary file web/fens_FabLab_Design_Metadata/images/tail_fens_fablab_fablab.jpg has changed
Binary file web/images/sendusfeedback.png has changed
--- a/web/index.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/index.php	Tue Aug 09 13:07:23 2011 +0200
@@ -103,6 +103,7 @@
 	</script>
   </head>
   <body>
+	<div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
     <div class="container">
       <img src="images/ENMI_2010_logo.gif" class="logo">
 	  <ul class="menu"> 
--- a/web/mashup/config.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/mashup/config.php	Tue Aug 09 13:07:23 2011 +0200
@@ -1,10 +1,5 @@
 <?php
 
-/**
- * FAKE ONE 
- * Please edit the conférence details 
- * 
- */
 $config = array(
     'hashtag'    => '#mashup',
     'date'   	 => '25.06.2011',
--- a/web/polemicaltimeline.php	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/polemicaltimeline.php	Tue Aug 09 13:07:23 2011 +0200
@@ -169,7 +169,7 @@
 	</script>
   </head>
   <body>
-  
+  <div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>
 
   <!-- tooltip --> 
   <div id="tip">
@@ -192,9 +192,9 @@
 	  <?php print $translate->_("Archives"); ?></a></li>
 	  </ul>
 	  	  
-	<?php if(is_array($config['metadata'])):?>
+	<?php if(is_array($config['metadata'])): ?>
 	<ul id="content_select_ul" class="menu mdselect">
-	    <?php print $translate->_("changer de contenu"); ?><br/>
+	    <span><?php print $translate->_("changer de contenu"); ?></span><br/>
 	    <select id="mdselect">
 	    	<?php foreach ($config['metadata'] as $key => $value):?>
 	    	<option value="<?php echo($key); ?>" id="mdselect_<?php echo($key); ?>" ><?php echo($value['display']); ?></option>
@@ -202,10 +202,10 @@
 	    </select>
 	</ul>
 	<ul class="menu shortlang" >
-	<?php else:?>
+	<?php else: ?>
 	<ul class="menu lang" >
 	<?php endif;?>	  
-	  <li class="menuUnderline"><a href="<?php echo(URL_ROOT.$rep) ?>/polemicaltimeline.php?lang=ja_JP" class="menuLink" >
+	  <li class="menuUnderline"><a href="<?php echo(URL_ROOT.$rep);?>/polemicaltimeline.php?lang=ja_JP" class="menuLink" >
 	       <img src="<?php echo(URL_ROOT)?>images/flag_jp.gif"<?php if($actual!="ja_JP"){echo("style='opacity: .5;'"); } ?> />
 	        <?php print $translate->_("Japonais"); ?></a></li>
 	  <li class="menuUnderline"><a href="<?php echo(URL_ROOT.$rep) ?>/polemicaltimeline.php?lang=fr" class="menuLink">
--- a/web/res/css/custom.css	Tue Aug 09 12:41:37 2011 +0200
+++ b/web/res/css/custom.css	Tue Aug 09 13:07:23 2011 +0200
@@ -34,9 +34,10 @@
 .menuLink:active {text-decoration:none;}
 .menuLink:visited {text-decoration:none;}
 .mdselect{width: 150px}
-.mdselect select {margin-left:5px; width: 100px}
+.mdselect span {margin-left:5px;}
+.mdselect select {margin-left:5px; width: 120px}
 .lang{margin-left:350px;}
-.shortlang{margin-left:300px;}
+.shortlang{margin-left:200px;}
 
 .tweetContainer{position:absolute; margin-top:70px;}
 .tweetWriter{background-image:url(../../images/tweetWriterBgd.gif);width:359px;height:136px;padding:10px;position:absolute; margin-top:70px;}
@@ -167,4 +168,13 @@
 /* disabled navigational button */
 #actions a.disabled {
     visibility:hidden !important;       
-}  
\ No newline at end of file
+}  
+/* send us feedback */
+#sendUsFeedBack{
+	float:right;
+	position:absolute;
+	right:0px;
+	top:0px;
+	z-index:999999;
+	width:100px;
+}
\ No newline at end of file