From 709c86b2daec32ae0d5d6d0e7f88b8607e02edba Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 20 Aug 2010 14:33:15 -0700 Subject: [PATCH] added location tagging --- database.sql | 1 + images/globe.gif | Bin 0 -> 1025 bytes include/items.php | 11 +++++++++-- include/notifier.php | 3 ++- mod/item.php | 6 ++++-- view/atom_feed.tpl | 3 ++- view/atom_item.tpl | 1 + view/jot-header.tpl | 8 ++++++++ view/jot.tpl | 4 ++++ view/theme/default/style.css | 6 +++++- 10 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 images/globe.gif diff --git a/database.sql b/database.sql index 1809f4703b..af1ec630f2 100644 --- a/database.sql +++ b/database.sql @@ -331,6 +331,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `nickname` char(255) NOT NULL, `email` char(255) NOT NULL, `timezone` char(128) NOT NULL, + `default-location` char(255) NOT NULL, `theme` char(255) NOT NULL, `pubkey` text NOT NULL, `prvkey` text NOT NULL, diff --git a/images/globe.gif b/images/globe.gif new file mode 100644 index 0000000000000000000000000000000000000000..3f17c5d322d90d6093ebb9a62ddcb008f903e9ea GIT binary patch literal 1025 zcmeH`L2DC17=|ZFlWvOEZ3RumY7@K!E6s|gS@p2)LEBhM40@AY5DR;-mGPnjJviRxP?arG8R%sYk)fb46@}^i0K^ z(t!>_06>udg90M}1_K5Mh5#l5CI@CL5||3uN;9ZtQqAU?Ep(IUCe`gAX9hW&=3=SK ze3j(mJHd;NEIP`lGsBU_tTJXpbAs71P7JqaS=9}yE~_?p-4*pVpK!U;z>XKVZR~oY z@fX>ExB+<^A`fB@1|Fgia~~2PV;@VOK%X$=QxpedL?j|At{_S=QJ5;sFcuy`Z9)(s zn2?B2L})|;MS_shkOqjx!XOnMl^#_vU?>niBOYUvv5>Kdal&}Wc*G>++~eHm!WSG0 z5lQAtj->RZf>K3FU?qJOOBjX94?`5j68+D=@qzrWjsyS^7>uV7FG2^FCP0+kzkT)n zV>8uhXG@^9*-_wRNucvN-L|0#Vd}h1Z`r0wM)F}kPhtdxou@>Z>Nc-NDWhslM^4s9e;`*D5h+?{Os^Va6= z^k`=8Q)%q-@kI9Mr3ba1Wd2$AN_YQ>T5qtPE~GZ*C(X%b>!4AXuRZ$tVt2pw^y64g H2Pgjk?;Xx& literal 0 HcmV?d00001 diff --git a/include/items.php b/include/items.php index 74809583c3..aeb89892ea 100644 --- a/include/items.php +++ b/include/items.php @@ -120,7 +120,8 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$title' => xmlify($item['title']), '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), + '$location' => xmlify($item['location']), + '$content' => xmlify($item['body']), '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) )); } @@ -174,6 +175,11 @@ function get_atom_elements($item) { if($rawcreated) $res['created'] = unxmlify($rawcreated[0]['data']); + $rawlocation = $item->get_item_tags('http://activitystrea.ms/spec/1.0/', 'place'); + if($rawlocation) + $res['location'] = unxmlify($rawlocation[0]['data']); + + $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); if($rawedited) $res['edited'] = unxmlify($rawcreated[0]['data']); @@ -204,6 +210,7 @@ function post_remote($a,$arr) { $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); + $arr['location'] = notags(trim($arr['location'])); $arr['body'] = escape_tags(trim($arr['body'])); $arr['last-child'] = intval($arr['last-child']); $arr['visible'] = 1; @@ -213,7 +220,7 @@ function post_remote($a,$arr) { $parent_id = 0; dbesc_array($arr); -//dbg(3); + $r = q("INSERT INTO `item` (`" . implode("`, `", array_keys($arr)) . "`) VALUES ('" diff --git a/include/notifier.php b/include/notifier.php index ff18dd9b4f..d00ef54f43 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -176,7 +176,7 @@ $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), - '$content' =>xmlify($item['body']), + '$content' => xmlify($item['body']), '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => 0 )); @@ -209,6 +209,7 @@ $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), + '$location' => xmlify($item['location']), '$content' =>xmlify($item['body']), '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) )); diff --git a/mod/item.php b/mod/item.php index c658a871d5..5b81f13eeb 100644 --- a/mod/item.php +++ b/mod/item.php @@ -72,6 +72,7 @@ function item_post(&$a) { $title = notags(trim($_POST['title'])); $body = escape_tags(trim($_POST['body'])); + $location = notags(trim($_POST['location'])); if(! strlen($body)) { notice( t('Empty post discarded.') . EOL ); @@ -142,8 +143,8 @@ function item_post(&$a) { $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, - `edited`, `uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) - VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + `edited`, `uri`, `title`, `body`, `location`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) + VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), dbesc($post_type), intval($contact_id), @@ -158,6 +159,7 @@ function item_post(&$a) { dbesc($uri), dbesc($title), dbesc($body), + dbesc($location), dbesc($str_contact_allow), dbesc($str_group_allow), dbesc($str_contact_deny), diff --git a/view/atom_feed.tpl b/view/atom_feed.tpl index fc2816ef97..b77b146463 100644 --- a/view/atom_feed.tpl +++ b/view/atom_feed.tpl @@ -2,7 +2,8 @@ + xmlns:dfrn="http://purl.org/macgirvin/dfrn/1.0" + xmlns:as="http://activitystrea.ms/spec/1.0/" > $feed_id $feed_title diff --git a/view/atom_item.tpl b/view/atom_item.tpl index 16581fc897..99b18e05f7 100644 --- a/view/atom_item.tpl +++ b/view/atom_item.tpl @@ -15,5 +15,6 @@ $published $updated $content + $location $comment_allow diff --git a/view/jot-header.tpl b/view/jot-header.tpl index b13a324bba..39f8adc6ef 100644 --- a/view/jot-header.tpl +++ b/view/jot-header.tpl @@ -80,6 +80,14 @@ tinyMCE.init({ } } + function jotGetLocation() { + reply = prompt("Where are you right now?"); + if(reply && reply.length) { + $('#jot-location').val(reply); + } + } + + function linkdropper(event) { var linkFound = event.dataTransfer.types.contains("text/uri-list"); if(linkFound) diff --git a/view/jot.tpl b/view/jot.tpl index 481ab125b7..5ceb795037 100644 --- a/view/jot.tpl +++ b/view/jot.tpl @@ -9,6 +9,7 @@ + @@ -24,6 +25,9 @@
Insert YouTube video
+
+ Set your location +
diff --git a/view/theme/default/style.css b/view/theme/default/style.css index 872fb1f615..57d2888f48 100644 --- a/view/theme/default/style.css +++ b/view/theme/default/style.css @@ -720,10 +720,14 @@ input#dfrn-url { float: left; margin-left: 20px; } +#profile-location-wrapper { + float: left; + margin-left: 20px; +} #profile-jot-perms { float: left; - margin-left: 250px; + margin-left: 200px; } #profile-jot-perms-end {