]> git.mxchange.org Git - friendica-addons.git/commitdiff
uhremotestorage: update webfinger link
authorFabio Comuni <fabrix.xm@gmail.com>
Mon, 19 Dec 2011 08:35:24 +0000 (09:35 +0100)
committerFabio Comuni <fabrix.xm@gmail.com>
Mon, 19 Dec 2011 08:35:24 +0000 (09:35 +0100)
uhremotestorage.tgz
uhremotestorage/settings.tpl
uhremotestorage/uhremotestorage.php

index 2654cd0317dc7bf6f9d9a36f3c72aff73e08767c..5515aeaa531754c10a571fd30815fb825a7cd9a0 100644 (file)
Binary files a/uhremotestorage.tgz and b/uhremotestorage.tgz differ
index 45036dd4d1c63a802737b0bd444662f855b9769a..22d7d608419bcd7e119a23b3ab4fdc3d9341961c 100644 (file)
@@ -2,5 +2,8 @@
        <h3>$title</h3>
        <p>$desc</p>
        {{ inc field_input.tpl with $field=$url }}{{ endinc }}
+       {{ inc field_input.tpl with $field=$auth }}{{ endinc }}
+       {{ inc field_select.tpl with $field=$api }}{{ endinc }}
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>      
+
 </div>
index 5c1820042b988a7a16c4a26944f2557285892a73..3b8ab34c231dac837fa3f415ba4826a9f9d20e81 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Name: unhosted remote storage
  * Description: Expose in user XRD the link to external user's unhosted-enabled storage
- * Version: 1.0
+ * Version: 1.2
  * Author: Fabio Comuni <http://kirgroup.com/profile/fabrixxm>
  */
  
@@ -25,12 +25,19 @@ function uhremotestorage_uninstall() {
 }
 
 function uhremotestorage_personal_xrd($a, &$b){
+       list($user, $host) = explode("@",$_GET['uri']);
+       $user = str_replace("acct:","",$user);
+       $r = q("SELECT uid FROM user WHERE nickname='%s'", dbesc($user));
+       $uid = $r[0]['uid'];
        
-       $davurl = get_pconfig($b['user']['uid'],'uhremotestorage','davurl');
-       if ($davurl){
+       $url = get_pconfig($uid,'uhremotestorage','unhoestedurl');
+       $auth = get_pconfig($uid,'uhremotestorage','unhoestedauth');
+       $api = get_pconfig($uid,'uhremotestorage','unhoestedapi');
+       
+       if ($url){
                $b['xml'] = str_replace(
                        '</XRD>', 
-                       "\t".'<Link rel="http://unhosted.org/spec/dav/0.1" href="'.$davurl.'"/>'."\n</XRD>",
+                       "\t".'<Link rel="remoteStorage" template="'.$url.'" api="'.$api.'" auth="'.$auth.'" ></Link>'."\n</XRD>",
                        $b['xml']
                );
        }
@@ -39,7 +46,9 @@ function uhremotestorage_personal_xrd($a, &$b){
 function uhremotestorage_settings_post($a, $post){
        if(! local_user())
                return;
-       set_pconfig(local_user(),'uhremotestorage','davurl',$_POST['unhoestedurl']);
+       set_pconfig(local_user(),'uhremotestorage','unhoestedurl',$_POST['unhoestedurl']);
+       set_pconfig(local_user(),'uhremotestorage','unhoestedauth',$_POST['unhoestedauth']);
+       set_pconfig(local_user(),'uhremotestorage','unhoestedapi',$_POST['unhoestedapi']);
 }
 
 function uhremotestorage_settings($a, &$s){
@@ -48,13 +57,35 @@ function uhremotestorage_settings($a, &$s){
        
        $uid = $a->user['nickname'] ."@". $a->get_hostname();
        
-       $davurl = get_pconfig(local_user(),'uhremotestorage','davurl');
+       $url = get_pconfig(local_user(),'uhremotestorage','unhoestedurl');
+       $auth = get_pconfig(local_user(),'uhremotestorage','unhoestedauth');
+       $api = get_pconfig(local_user(),'uhremotestorage','unhoestedapi');
+       
        
+       $arr_api = array(
+               'WebDAV' => "WebDAV",
+               'simple' => "simple WebDAV",
+               'CouchDB' => "CouchDB",
+       );
+       /* experimental apis */
+       /*
+       $api = array_merge($api, array(
+               'git' => "git",
+               'tahoe-lafs' => 'tahoe-lafs',
+               'camlistore' => 'camlistore',
+               'AmazonS3' => 'AmazonS3',
+               'GoogleDocs' => 'GoogleDocs',
+               'Dropbox' => 'Dropbox',
+       );
+       */
        $tpl = file_get_contents(dirname(__file__)."/settings.tpl");
        $s .= replace_macros($tpl, array(
                '$title' => 'Unhosted remote storage',
-               '$desc' => sprintf( t('Allow to use your friendika id (%s) to connecto to external unhosted-enabled storage (like ownCloud)'), $uid ),
-               '$url'  => array( 'unhoestedurl', t('Unhosted DAV storage url'), $davurl, 'If your are using ownCloud, your unhosted url will be like <tt>http://<i>HOST</i>/apps/remoteStorage/compat.php/<i>USER</i>/remoteStorage/</tt>'),
+               '$desc' => sprintf( t('Allow to use your friendika id (%s) to connecto to external unhosted-enabled storage (like ownCloud). See <a href="http://www.w3.org/community/unhosted/wiki/RemoteStorage#WebFinger">RemoteStorage WebFinger</a>'), $uid ),
+               '$url'  => array( 'unhoestedurl', t('Template URL (with {category})'), $url, 'If your are using ownCloud, your unhosted url will be like <tt>http://<i>HOST</i>/apps/remoteStorage/WebDAV.php/<i>USER</i>/remoteStorage/{category}</tt>'),
+               '$auth' => array( 'unhoestedauth', t('OAuth end-point'), $auth, 'If your are using ownCloud, your OAuth endpoint will be like <tt>http://<i>HOST</i>/apps/remoteStorage/auth.php/<i>USER</i></tt>'),
+               '$api'  => array( 'unhoestedapi', t('Api'), $api, 'If your are using ownCloud, your api will be <tt>WebDAV</tt>', $arr_api),
+               
                '$submit' => t('Submit'),
        ));