Преглед на файлове

Archive generator and some minor fixes

pecesama преди 16 години
родител
ревизия
2949a49c30
променени са 7 файла, в които са добавени 383 реда и са изтрити 21 реда
  1. 119 0
      admin/css/archive.css
  2. 1 1
      api.php
  3. 251 0
      archive.php
  4. 3 2
      classes/functions.php
  5. 2 10
      classes/gelato.class.php
  6. 2 3
      entry.php
  7. 5 5
      notice.txt

+ 119 - 0
admin/css/archive.css Целия файл

@@ -0,0 +1,119 @@
1
+body {
2
+	background: white;
3
+	font-family: "Lucida Sans";
4
+	font-size: 15px;
5
+	letter-spacing: 2px;
6
+	line-height: 30px;
7
+}
8
+
9
+#dash {
10
+	margin: 35px auto 0px auto;
11
+	padding: 10px;
12
+	width: 85%;
13
+}
14
+
15
+#options {
16
+	width:100%;
17
+	text-align: center;
18
+	border-bottom: thin solid white;
19
+}
20
+
21
+li {
22
+	list-style: none;
23
+	margin-bottom: 5px;
24
+}
25
+
26
+ul {
27
+	padding: 0px;
28
+	margin: 0px;
29
+}
30
+
31
+h4 {
32
+	margin-top: 0px;
33
+	font-size: 12px;
34
+	font-weight: bold;
35
+	font-variant: small-caps;
36
+	text-align: center;
37
+}
38
+
39
+#options li {
40
+	display: inline;
41
+	padding: 10px;
42
+	color: #999;	
43
+	font-variant: small-caps;
44
+}
45
+
46
+#options li a {
47
+	text-decoration: none;
48
+	padding:10px 20px;
49
+	color: #999;
50
+}
51
+
52
+#options li a:hover {
53
+	background-color: #382513;
54
+	color: #FFF;
55
+}
56
+
57
+#options li a.selected {
58
+	background-color: #382513;
59
+	color: #FFF;
60
+}
61
+
62
+#content {
63
+	padding: 25px;
64
+	width:auto;
65
+}
66
+
67
+.item {
68
+	height: 110px;
69
+	width: 110px;
70
+	padding: 5px;
71
+	overflow: hidden;
72
+	border: thin solid #CCC;
73
+	border-top: 2px solid #444;
74
+	float:left;
75
+	margin: 10px;
76
+	color: #222;
77
+	text-align: left;
78
+	background-color: #FEFEFE;
79
+	font-size: 11px;
80
+	line-height: normal;
81
+}
82
+
83
+.link {
84
+	font-size: 16px;
85
+}
86
+
87
+div.user_hover {
88
+	background-color:#000000;
89
+	color:#FFFFFF;
90
+	display:none;
91
+	font-family:Helvetica,sans-serif;
92
+	font-size:18px;
93
+	font-size-adjust:none;
94
+	font-stretch:normal;
95
+	font-style:normal;
96
+	font-variant:normal;
97
+	font-weight:bold;
98
+	line-height:normal;
99
+	opacity:0.75;
100
+	padding:5px;
101
+	position:absolute;
102
+	text-align:center;
103
+	z-index:10;
104
+	height:113px;
105
+	width: 112px;
106
+	margin:10px;
107
+	cursor: pointer;
108
+}
109
+
110
+li:hover div.user_hover {
111
+	display:block;
112
+}
113
+
114
+ul.item_list {
115
+	 width:112px; 
116
+	 float:left; 
117
+	 position:relative; 
118
+	 margin:10px;
119
+}

+ 1 - 1
api.php Целия файл

@@ -82,7 +82,7 @@ if(!defined('entry')) define('entry',true);
82 82
 <?php
83 83
 							$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
84 84
 ?>
85
-                            <photo-caption><?php echo $tit;?></photo-caption>
85
+                            <photo-caption><?php echo stripslashes($tit);?></photo-caption>
86 86
                             <photo-url><?php echo $photoPath;?></photo-url>                            
87 87
                         </post>
88 88
 <?php

+ 251 - 0
archive.php Целия файл

@@ -0,0 +1,251 @@
1
+<?php
2
+if(!defined('entry'))define('entry', true);
3
+ /* ===========================
4
+
5
+  gelato CMS - A PHP based tumblelog CMS
6
+  development version
7
+  http://www.gelatocms.com/
8
+
9
+  gelato CMS is a free software licensed under the GPL 2.0
10
+  Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
11
+
12
+  =========================== */
13
+?>
14
+<?php
15
+require('entry.php');
16
+global $user, $tumble, $conf;
17
+
18
+$quote = array();
19
+$conversation = array();
20
+$link = array();
21
+$photo = array();
22
+$regular = array();
23
+$video = array();
24
+
25
+$rs = $tumble->getPosts($tumble->getPostsNumber());
26
+if ($tumble->contarRegistros()>0) {
27
+    while($register = mysql_fetch_assoc($rs)) {
28
+    	$output = handleNode($register);
29
+    	
30
+		$theType = type2Text($register["type"]);
31
+		
32
+    	switch($theType) {
33
+			case 'quote':
34
+				$quote[] = $output;
35
+				continue;
36
+			case 'conversation':
37
+				$conversation[] = $output;
38
+				continue;
39
+			case 'url':
40
+				$link[] = $output;
41
+				continue;
42
+			case 'photo':
43
+				$photo[] = $output;
44
+				continue;
45
+			case 'post':
46
+				$regular[] = $output;
47
+				continue;
48
+			case 'video':
49
+				$video[] = $output;
50
+				continue;
51
+		}
52
+    }
53
+}
54
+
55
+function handleNode($node) {
56
+		global $user, $tumble, $conf;
57
+		$dateTmp = null;
58
+		$formatedDate = gmdate("M d", strtotime($node["date"]) + transform_offset($conf->offsetTime));
59
+        
60
+		$output = array();		
61
+		$output['url'] = $tumble->getPermalink($node["id_post"]);
62
+ 		$output['date'] = $formatedDate;
63
+ 		
64
+ 		$theType = type2Text($node["type"]);
65
+ 		
66
+		switch($theType) {
67
+			case 'quote':
68
+				$output['quote'] = $node["description"];
69
+				$output['source'] = $node["title"];                                        		
70
+				break;
71
+			case 'conversation':				
72
+				$output['lines'] = $tumble->formatConversation($node["description"]);
73
+				break;
74
+			case 'url':								
75
+				$node["title"] = (empty($node["title"]))? $node["url"] : $node["title"];				
76
+				$output['text'] = $node["title"];
77
+				$output['link'] = $node["url"];
78
+				break;
79
+			case 'photo':				
80
+				$fileName = "uploads/".getFileName($node["url"]);
81
+				$x = @getimagesize($fileName);
82
+                if ($x[0] > 500) {
83
+					$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$node["url"];
84
+                } else {
85
+					$photoPath = str_replace("../", $conf->urlGelato."/", $node["url"]);
86
+               	}				
87
+				$output['caption'] = $node["description"];
88
+				$output['photo'] = $photoPath;
89
+				break;
90
+			case 'post':				
91
+				$output['title'] = $node["title"];
92
+				$output['body'] = $node["description"];
93
+				break;
94
+			case 'video':				
95
+				$output['caption'] = $node["description"];
96
+				$temp = $tumble->getVideoPlayer($node["url"]);
97
+				$patterns[0] = "/width='[0-9]+'/";
98
+				$patterns[1] = "/height='[0-9]+'/";
99
+				$replace[0] = "width='100'"; 
100
+				$replace[1] = "height='75'";
101
+				$embed = preg_replace($patterns, $replace, $temp);
102
+				$output['embed'] = $embed;
103
+		}
104
+		return $output;
105
+	}
106
+?>
107
+
108
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
109
+	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
110
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
111
+
112
+	<head>
113
+    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
114
+        <meta name="generator" content="gelato <?php echo codeName()." (".version().")"; ?>" />
115
+        <link rel="shortcut icon" href="<?php echo $conf->urlGelato;?>/images/favicon.ico" />
116
+        <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $conf->urlGelato.($conf->urlFriendly ? "/rss/" : "/rss.php"); ?>"/>
117
+		<title><?php echo $conf->title." &raquo; ".__(" archive"); ?></title>
118
+		<script language="javascript" type="text/javascript" src="<?php echo $conf->urlGelato;?>/admin/scripts/jquery.js"></script>
119
+		<link href="<?php echo $conf->urlGelato;?>/admin/css/archive.css" type="text/css" rel="stylesheet">
120
+		<script type='text/javascript'>
121
+			function select(object) {
122
+				var sel_id = object.id;
123
+				$("a.option").removeClass('selected');
124
+				$(object).addClass('selected');
125
+				$("#conversation_content, #quote_content, #link_content, #regular_content, #photo_content, #video_content").hide("slow");
126
+				$("#"+sel_id+"_content").show("slow");
127
+			};
128
+		</script>
129
+	</head>
130
+	
131
+	<body>
132
+		
133
+		<div id='dash'>
134
+					
135
+			<div id='options'>
136
+				<ul id='option-list'>
137
+					<li><a href='#' id='conversation' class='option selected' onclick="select(this);">Conversations</a></li>
138
+					<li><a href='#' id='photo' class='option' onclick="select(this);">Photos</a></li>
139
+					<li><a href='#' id='link' class='option' onclick="select(this);">Links</a></li>
140
+					<li><a href='#' id='regular' class='option' onclick="select(this);">Posts</a></li>
141
+					<li><a href='#' id='quote' class='option' onclick="select(this);">Quotes</a></li>
142
+					<li><a href='#' id='video' class='option' onclick="select(this);">Videos</a></li>
143
+				</ul>
144
+			</div>
145
+			
146
+			<div id='content'>
147
+				<div id='conversation_content'>
148
+					<?php foreach($conversation as $item) { ?>
149
+					<ul class='item_list'>
150
+						<li>
151
+							<div class='item'>
152
+								<ul>									
153
+                                    <li><?php echo $item['lines']; ?></li>
154
+								</ul>
155
+							</div>
156
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
157
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
158
+							</div>
159
+						</li>
160
+					</ul>
161
+					<?php } ?>
162
+				</div>
163
+				
164
+				<div id='quote_content' style='display:none;'>
165
+					<?php foreach($quote as $item) { ?>
166
+					<ul class='item_list'>
167
+						<li>
168
+							<div class='item'>
169
+								<ul>
170
+									<li><em>"<?php echo substr($item['quote'], 0, 50), "..."; ?>"</em></li>
171
+									<li>--<?php echo $item['source']; ?></li>
172
+								</ul>
173
+							</div>
174
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
175
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
176
+							</div>
177
+						</li>
178
+					</ul>
179
+					<?php } ?>
180
+				</div>
181
+				
182
+				<div id='link_content' style='display:none;'>
183
+					<?php foreach($link as $item) { ?>
184
+					<ul class='item_list'>
185
+						<li>
186
+							<div class='item link'>
187
+								<ul>
188
+									<li><a href="<?php echo $item['link']; ?>"><?php echo $item['text']; ?></a></li>
189
+								</ul>
190
+							</div>
191
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
192
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
193
+							</div>
194
+						</li>
195
+					</ul>
196
+					<?php } ?>
197
+				</div>
198
+				
199
+				<div id='photo_content' style='display:none;'>
200
+					<?php foreach($photo as $item) { ?>
201
+					<ul class='item_list'>
202
+						<li>
203
+							<div class='item' style="background-image:url('<?php echo $item['photo']; ?>')"></div>
204
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
205
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
206
+							</div>
207
+						</li>
208
+					</ul>
209
+					<?php } ?>
210
+				</div>
211
+				
212
+				<div id='regular_content' style='display:none;'>	
213
+					<?php foreach($regular as $item) { ?>
214
+					<ul class='item_list'>
215
+						<li>
216
+							<div class='item'>
217
+								<h4><?php echo $item['title']; ?></h4>
218
+								<p><?php echo $item['body']; ?></p>
219
+							</div>
220
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
221
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
222
+							</div>
223
+						</li>
224
+					</ul>
225
+					<?php } ?>
226
+				</div>
227
+				
228
+				<div id='video_content' style='display:none;'>
229
+					<?php foreach($video as $item) { ?>
230
+					<ul class='item_list'>
231
+						<li>
232
+							<div class='item' style='text-align:center;'>
233
+								<?php echo  $item['embed']; //$item['caption'] ?>								
234
+							</div>
235
+							<div class='user_hover' onclick="location.href='<?php echo $item['url'] ?>';">
236
+								<h3><?php echo strftime("%b %d, %G", strtotime($item['date'])); ?></h3>
237
+							</div>
238
+						</li>
239
+					</ul>
240
+					<?php } ?>
241
+				</div>
242
+
243
+			</div>
244
+			
245
+			<br clear='both' />
246
+			
247
+		</div>
248
+		
249
+	</body>
250
+
251
+</html>

+ 3 - 2
classes/functions.php Целия файл

@@ -488,8 +488,9 @@ if(!defined('entry') || !entry) die('Not a valid page');
488 488
 	}
489 489
 
490 490
 	function trimString($string, $len = "") {
491
-		if($len>strlen($string) or $len<1)
492
-			return $string;
491
+		if($len>strlen($string) or $len<1) {		
492
+			return strip_tags($string);
493
+		}
493 494
 		$string = strip_tags($string);
494 495
 		$len = (empty($len)) ? "50" : $len ;
495 496
 		return ( strpos($string, " ", $len) ) ? substr_replace($string, "...", $len) : $string ;

+ 2 - 10
classes/gelato.class.php Целия файл

@@ -199,14 +199,6 @@ class gelato extends Conexion_Mysql {
199 199
 		$out .= ($this->conf->urlFriendly) ? "/post/" : "/index.php?post=";
200 200
 		$out .= $post_id.$strEnd;
201 201
 		return $out;
202
-	}
203
-
204
-	function getPermalink($post_id){
205
-		$strEnd = ($this->conf->urlFriendly) ? "/" : "";
206
-		$out = $this->conf->urlGelato;
207
-		$out .= ($this->conf->urlFriendly) ? "/post/" : "/index.php?post=";
208
-		$out .= $post_id.$strEnd;
209
-		return $out;
210
-	}
202
+	}	
211 203
 }
212
-?>
204
+?>

+ 2 - 3
entry.php Целия файл

@@ -81,6 +81,5 @@ if($installed){
81 81
 	$feeds = new feeds();
82 82
 	$feeds->updateFeeds();
83 83
 	unset($feeds);
84
-}
85
-?>
86
-
84
+}
85
+?>

+ 5 - 5
notice.txt Целия файл

@@ -11,8 +11,12 @@ Juan del Rio [ http://elcaminante.net/ ]
11 11
 = COPYRIGHT NOTICES =
12 12
 This product includes code and libraries developed by third parties, which are governed by different licenses.  These components, and their licenses, are listed below.
13 13
 
14
+= Archive based on code from: simple Tumblr API processor =
15
+Copyright (c) Vivek, http://www.stageleftstudios.com
16
+simple Tumblr API processor is available under Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
17
+
14 18
 = markItUp! Universal MarkUp Engine, JQuery plugin =
15
-Copyright (C) 2007-2008 Jay Salvat, http://markitup.jaysalvat.com/
19
+Copyright (c) 2007-2008 Jay Salvat, http://markitup.jaysalvat.com/
16 20
 markItUp is available under a dual licensed the MIT and GPL licenses.
17 21
 
18 22
 = NicEdit - Micro Inline WYSIWYG =
@@ -47,10 +51,6 @@ Clase Conexion_Mysql available under MIT license.
47 51
 Copyright (c) Victor De la Rocha, http://www.mis-algoritmos.com/
48 52
 Digg Style Paginator Class available under MIT license.
49 53
 
50
-= Clase plantillas =
51
-Copyright (c) Pedro Santana, http://www.pecesama.net/weblog/
52
-Clase plantillas available under MIT license.
53
-
54 54
 = Textile class =
55 55
 Copyright (c) 2003-2004, Dean Allen, http://textile.thresholdstate.com/
56 56
 Textile class available under GNU General Public License.