]> git.quilime.com - plog.git/commitdiff
Getting editing working again.
authorGabriel Dunne <gdunne@quilime.com>
Tue, 4 Sep 2012 00:07:45 +0000 (17:07 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Tue, 4 Sep 2012 00:07:45 +0000 (17:07 -0700)
28 files changed:
content/config [changed mode: 0644->0755]
content/log/islands [changed mode: 0644->0755]
content/log/overlords [changed mode: 0644->0755]
content/log/temple [changed mode: 0644->0755]
content/log/water_is_life [changed mode: 0644->0755]
content/projects/.audio [changed mode: 0644->0755]
content/projects/.egg [changed mode: 0644->0755]
content/projects/.obsession [changed mode: 0644->0755]
content/projects/.rattle [changed mode: 0644->0755]
content/projects/.stars [changed mode: 0644->0755]
content/projects/.statement_2007 [changed mode: 0644->0755]
content/projects/.tessellated [changed mode: 0644->0755]
content/projects/.web [changed mode: 0644->0755]
content/projects/config [changed mode: 0644->0755]
content/projects/mask [changed mode: 0644->0755]
content/projects/prism [changed mode: 0644->0755]
data/content/log/tags.json [deleted file]
data/content/projects/tags.json [deleted file]
data/tags.json [deleted file]
index.php
lib/config.ini
lib/data.php
lib/edit.php [new file with mode: 0644]
lib/model.php
templates/archive.html.tpl
templates/edit.html.tpl [new file with mode: 0644]
templates/linked-archive.html.tpl [deleted file]
templates/photo.html.tpl [deleted file]

old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/data/content/log/tags.json b/data/content/log/tags.json
deleted file mode 100644 (file)
index da87f8a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"tags":{"photo":2,"water":1,"writing":1,"quote":2,"india":1}}
\ No newline at end of file
diff --git a/data/content/projects/tags.json b/data/content/projects/tags.json
deleted file mode 100644 (file)
index 7a2a5ff..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"tags":{"prism":1,"painting":2,"mask":1}}
\ No newline at end of file
diff --git a/data/tags.json b/data/tags.json
deleted file mode 100644 (file)
index 1d66e51..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{"tags":{"photo":2,"water":1,"writing":1,"quote":2,"india":1,"prism":1,"painting":2,"mask":1}}
\ No newline at end of file
index 7012cf246015ea926193770c5bf499f538cd7f60..6c9cf6d308596d8c279aaec56aa26fd5a2837721 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,7 +5,7 @@ require 'lib/init.php';
 
 
 $request = get_request();
-$m = new Model ($request);
+$m = new Model($request);
 $v = new View();
 
 
index 919a806c6d4ad069aeb0a59a172da09db722d7b0..885c226f4dd61ac58a85c5fbd87e2c2724d34f6f 100644 (file)
@@ -1,3 +1,6 @@
+[development]
+dev = true
+
 [settings]
 ; general settings
 site_title  = plog
@@ -35,8 +38,6 @@ file_ignores[] = config
 file_ignores[] = .DS_Store
 
 
-[development]
-dev = true
 
 
 ; define ('SITE_TITLE',        'quilime');
index 1888d802d418889edb1986a22352243e490bfe30..145dc7c1bca4367cff7753be6a19e45b182cdbd1 100644 (file)
@@ -169,7 +169,6 @@ function get_tags($path = "", $args = array() )
 
         $tags = array_count_values($tags);
 
-
         if ($create_datafile) {
             if (!is_dir($data_path)) {
                 if (!mkdir($data_path, 0777, true)) {
@@ -182,17 +181,9 @@ function get_tags($path = "", $args = array() )
             if (!file_exists( $data_file )) {
                 throw new Exception('Error creating tags json in get_tags(). Permissions?');
             }
-        }        
-
-
-        // $fp = fopen( $data_file, 'w');
-        // fwrite($fp, json_encode(array( 'tags' => $tags )));
-        // fclose($fp);
-        // if (!file_exists( $data_file)) {
-        //     throw new Exception('Error creating tags.json. Permissions?');
-        // }
+        }
     }
-
+    
     $json = json_decode(file_get_contents($data_file));
     return (array) $json->tags;
 }
diff --git a/lib/edit.php b/lib/edit.php
new file mode 100644 (file)
index 0000000..761a8c5
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+if (!DEV) 
+    break;
+
+array_shift($dirs);
+$newurl = implode($dirs, '/');
+$content_req = LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $newurl;
+$page_req =  LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $newurl;
+
+// TODO: Sercurity risk?
+if ($_SERVER['REQUEST_METHOD'] == 'POST' && 
+    isset($_POST['edited_file_contents']) && 
+    isset($_POST['edited_file'])) {
+    try {
+        $fp = fopen( $_POST['edited_file'], 'w');
+        if ($fp) {
+            fwrite($fp, $_POST['edited_file_contents']);
+            fclose($fp);
+        }
+        if (!file_exists( $_POST['edited_file'] )) {
+            throw new Exception('Error creating tags.json. Permissions?');
+        }
+    } catch (Exception $e) {
+        echo 'Caught exception: ',  $e->getMessage(), "\n";
+    }
+    $edit = false;
+} else {
+    $edit = true;
+}
index 44cf54b9aab6ce3d5105c0b5ece01b825674b345..ad5c215d522dd8d78197fe3362dbb0c473b1df87 100644 (file)
@@ -26,7 +26,30 @@ class Model
 
        function parse_request( $request )
        {
-           # if entries (dir in CONTENT dir)
+
+/*
+               $dirs = explode('/', $request['path']);
+               switch($dirs[0]) {
+                   # EDITING
+                   case 'edit' : 
+                       include 'edit.php';
+                       break;
+                   # TAG
+                   case 'tag' : 
+                       echo 'tag time.';
+                       exit;
+                       break;
+               }
+
+
+               # edit
+               if (DEV && isset($edit) && $edit) {
+               $this->template = 'edit.html.tpl';
+               }
+
+*/
+
+           # if multiple (multiple files in CONTENT dir)
            if ($this->is_multiple()) {
                        # check if config file exists in dir
                    if ($this->has_config()) {
index 6ba5573269504ac8e449f901ed80e6f782d589bf..204ac1733d034604d18739527414f4accd5c9c47 100644 (file)
 <div id="content">
 
     <ul class="archive">
-       <? foreach($entries as $entry): ?>
+    <? foreach($entries as $entry): ?>
     <li>
         &mdash; <a class="more" href="<?= $entry['url']; ?>"><?= $entry['title']; ?></a>
     </li>
-       <? endforeach; ?>       
+    <? endforeach; ?>   
     </ul>
-       
+    
 </div>
 
-       <? $this->include_template('footer.html.tpl') ?>
+    <? $this->include_template('footer.html.tpl') ?>
     <? $this->include_template('nav.html.tpl') ?>
 
 </body>
diff --git a/templates/edit.html.tpl b/templates/edit.html.tpl
new file mode 100644 (file)
index 0000000..e27c80f
--- /dev/null
@@ -0,0 +1,32 @@
+<html>
+<head>
+
+    <? $this->include_template('head-inc.html.tpl') ?>
+
+    <title><?=SITE_TITLE?><?=TITLE_DELIMITER?><?=$entry->title?></title>
+
+</head>
+<body>
+
+    <? $this->include_template('nav.html.tpl') ?>
+
+<div id="content" class="edit">
+
+    <? if ($entry): ?>
+    <? $fileContents = file_get_contents($entry->fileInfo); ?>
+
+    <form action="" method="POST">
+    <textarea name="edited_file_contents"><?=$fileContents?></textarea>
+    <input type="hidden" name="edited_file" value="<?=$entry->fileInfo->getPath().DIRECTORY_SEPARATOR.$entry->fileInfo->getFilename();?>">
+    <input type="button" onClick="window.location = '<?=$entry->url?>'"value="cancel">
+    <input type="submit" value="save">
+    </form>
+
+    <? endif; ?>
+
+</div>
+
+    <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>
diff --git a/templates/linked-archive.html.tpl b/templates/linked-archive.html.tpl
deleted file mode 100644 (file)
index 788e5ea..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<html>
-<head>
-    
-    <? $this->include_template('head-inc.html.tpl') ?>
-    
-    <title><?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?></title>
-    
-</head>
-<body>
-    
-    
-<div id="content">
-
-    <ul class="archive">
-    <? foreach($entries as $entry): ?>
-    <li>
-        <a class="more" href="#<?= $entry['url']; ?>"><?= $entry['title']; ?></a>
-    </li>
-    <? endforeach; ?>   
-    </ul>
-
-    <br />
-    <br />
-    <br />
-    <br />
-
-
-    <div class="inline">
-       <? foreach($entries as $entry): ?>
-       <?  
-        if (isset($entry['content_short'])) 
-            $entry['content'] = $entry['content_short'] . '<br /><a class="more" href="'.$entry['url'].'">more &rarr;</a><br /><br />';
-
-        ?>
-        <a name="<?= $entry['url'] ?>">
-        <?
-
-        $this->include_template('entry.html.tpl', array('entry' => $entry)); 
-    ?>
-       <? endforeach; ?>       
-    </div>
-       
-</div>
-
-       <? $this->include_template('footer.html.tpl') ?>
-    <? $this->include_template('nav.html.tpl') ?>
-
-</body>
-</html>
diff --git a/templates/photo.html.tpl b/templates/photo.html.tpl
deleted file mode 100644 (file)
index 83fde89..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<html>
-<head>
-    
-    <?php $this->include_template('head-inc.html.tpl'); ?>
-    
-    <title><?=SITE_TITLE?>: photo</title>
-    <style>
-       ul, li {
-               list-style-type:none;
-
-       }
-       ul {
-               margin:0;
-               padding:0;
-       }
-    </style>
-</head>
-<body>
-    
-    <? $this->include_template('nav.html.tpl') ?>
-    
-<div id="content">
-       
-
-
-<? /*
-               <td valign="top" class="column">
-               <?php $tube = get_rss_feed('http://gdata.youtube.com/feeds/base/users/quilime/favorites?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile'); ?>
-               <h2><a href="http://www.youtube.com/profile?user=kabr&view=favorites">video </a></h2>
-               <ul class="video">
-               <?php 
-               $count = 11;
-               foreach($tube->channel->item as $tube) :  
-               if ($count-- == 0) break;
-               ?>    
-               <li title="<?php echo str_replace('"', '\'', $tube->title); ?>">
-                   <? 
-                   $url = $tube->link;
-                   $pattern = '/v=(.+?)&/';
-                   preg_match($pattern, $url, $matches);
-                   $id = $matches[1];
-                   ?>
-                   <a href="<?php echo $tube->link; ?>">
-
-                   <img src="http://i3.ytimg.com/vi/<?=$id?>/default.jpg" />
-                   </a>
-               </li>
-               <? endforeach; ?>  
-               </ul>
-               <p>
-                   <a class="more" href="http://www.youtube.com/profile?user=quilime&view=favorites" title="via youtube">more &rarr;</a>            
-               </p>
-               </td>
-*/ ?>
-
-       <!-- quilime:flickr -->
-               <ul>
-               <?      $count = 16; $img = get_rss_feed('http://api.flickr.com/services/feeds/photos_public.gne?id=28394478@N00&lang=en-us&format=rss_200');  ?>
-        <?php foreach($img->channel->item as $item) : if (!$count--) break; ?>
-        <li style="float:left; height:280px;margin-right:20px;">
-            <?
-                $subject = $item->description;
-               $pattern = '/<a href="http:\/\/www\.flickr\.com\/photos\/quilime\/(.*) \/><\/a><\/p>/';
-                preg_match($pattern, substr($subject, 3), $matches, PREG_OFFSET_CAPTURE);
-                echo $matches[0][0];
-            ?>
-        </li>
-<?endforeach;?>
-       </ul>
-       <p style="clear:both;">
-
-       </p>
-       <p>
-       <a class="more" href="http://flickr.com/photos/quilime/" title="via flickr">more &rarr;</a>            
-       </p>
-
-
-
-
-       
-       
-       
-
-       
-       
-       
-
-       </div>
-
-       <? $this->include_template('footer.html.tpl'); ?>
-
-</body>
-</html>
-