summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php2
-rw-r--r--install.php10
-rw-r--r--js/util.js19
-rw-r--r--lib/attachmentlist.php4
-rw-r--r--lib/noticelist.php1
-rw-r--r--lib/router.php4
-rw-r--r--lib/util.php21
-rw-r--r--theme/base/css/display.css8
-rw-r--r--theme/base/images/icons/clip-inline.pngbin0 -> 1646 bytes
9 files changed, 59 insertions, 10 deletions
diff --git a/index.php b/index.php
index 9ff1c2c56..c2972ec5f 100644
--- a/index.php
+++ b/index.php
@@ -64,7 +64,7 @@ function handleError($error)
function main()
{
// quick check for fancy URL auto-detection support in installer.
- if (isset($_SERVER['REDIRECT_URL']) && ('/check-fancy' === $_SERVER['REDIRECT_URL'])) {
+ if (isset($_SERVER['REDIRECT_URL']) && ((dirname($_SERVER['REQUEST_URI']) . '/check-fancy') === $_SERVER['REDIRECT_URL'])) {
die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs.");
}
global $user, $action, $config;
diff --git a/install.php b/install.php
index 1d411c221..133f2b30f 100644
--- a/install.php
+++ b/install.php
@@ -117,16 +117,16 @@ function showForm()
<p class="form_guide" id='fancy-form_guide'>Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.</p>
</li>
<li>
- <label for="host">Hostname</label>
- <input type="text" id="host" name="host" />
- <p class="form_guide">Database hostname</p>
- </li>
- <li>
<label for="host">Site path</label>
<input type="text" id="path" name="path" value="$config_path" />
<p class="form_guide">Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.</p>
</li>
<li>
+ <label for="host">Hostname</label>
+ <input type="text" id="host" name="host" />
+ <p class="form_guide">Database hostname</p>
+ </li>
+ <li>
<label for="host">Database</label>
<input type="text" id="database" name="database" />
<p class="form_guide">Database name</p>
diff --git a/js/util.js b/js/util.js
index 6511c0380..9ee2a1963 100644
--- a/js/util.js
+++ b/js/util.js
@@ -20,7 +20,24 @@ $(document).ready(function(){
// attachments and attachment pages not used at the moment except for attachment_ajax version
// $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
// }, url:$(this).attr('href') + '/ajax'}); return false; });
- $('.attachment').click(function() {$().jOverlay({url:'../attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
+
+ //FIXME
+ //need to link to proper url depending on site config (path name and theme, for instance)
+ $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
+ $('.entry-title a.attachment').append('&nbsp;<img style="display: inline; vertical-align: middle" src="/theme/base/images/icons/clip-inline.png" alt="Attachment" />');
+ $('a.thumbnail').hover(function() {
+ anchor = $(this);
+ $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
+ anchor.append(data);
+ $('#thumbnail').fadeIn('def');
+ });
+ },
+ function() {
+ setTimeout(function() {
+ $('#thumbnail').fadeOut('slow', function() {$(this).remove();});
+ }, 500);
+ }
+ );
// count character on keyup
function counter(event){
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index 1be7b2fee..52aa5d9ee 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -171,7 +171,7 @@ class AttachmentListItem extends Widget
}
function linkTitle() {
- return 'Our page for ' . $this->title();
+ return $this->title();
}
/**
@@ -256,7 +256,7 @@ class Attachment extends AttachmentListItem
}
function linkTitle() {
- return 'Direct link to ' . $this->title();
+ return $this->attachment->url;
}
function showRepresentation() {
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 51b8987fe..ae1438892 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -180,7 +180,6 @@ class NoticeListItem extends Widget
{
$this->showStart();
$this->showNotice();
- $this->showNoticeAttachmentsIcon();
$this->showNoticeInfo();
$this->showNoticeOptions();
$this->showNoticeAttachments();
diff --git a/lib/router.php b/lib/router.php
index 39c005609..d1e2970c5 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -159,6 +159,10 @@ class Router
array('action' => 'attachment_ajax'),
array('attachment' => '[0-9]+'));
+ $m->connect('attachment/:attachment/thumbnail',
+ array('action' => 'attachment_thumbnail'),
+ array('attachment' => '[0-9]+'));
+
/*
TODO
not used right now, will revisit later
diff --git a/lib/util.php b/lib/util.php
index fbef8764a..d56f44f7b 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -496,6 +496,27 @@ function common_linkify($url) {
}
$attrs = array('href' => $longurl, 'rel' => 'external');
+
+// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID'
+// where ID is the id of the attachment for the given URL.
+ $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'";
+ $file = new File;
+ $file->query($query);
+ $file->fetch();
+
+ if (!empty($file->file_id)) {
+ $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'";
+ $file2 = new File;
+ $file2->query($query);
+ $file2->fetch();
+
+ if (empty($file2->file_id)) {
+ $attrs['class'] = 'attachment';
+ } else {
+ $attrs['class'] = 'attachment thumbnail';
+ }
+ $attrs['id'] = "attachment-{$file->file_id}";
+ }
return XMLStringer::estring('a', $attrs, $display);
}
diff --git a/theme/base/css/display.css b/theme/base/css/display.css
index 8f72460a8..71a434c54 100644
--- a/theme/base/css/display.css
+++ b/theme/base/css/display.css
@@ -1205,3 +1205,11 @@ display:none;
.guide {
clear:both;
}
+
+#thumbnail {
+position:absolute;
+z-index: 999;
+display: none;
+left: 100px;
+}
+
diff --git a/theme/base/images/icons/clip-inline.png b/theme/base/images/icons/clip-inline.png
new file mode 100644
index 000000000..870f8b2e8
--- /dev/null
+++ b/theme/base/images/icons/clip-inline.png
Binary files differ