Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Developing Attachments 2.0

edited August 2006 in Vanilla 1.0 Help
For all people who are interested: I've started Developing Attachments 2.0!

A brief history
When I started on Attachments 1, I was a Lussumo n00b... Although I had quite an understanding about the Framework, I overlooked many functions and posibilities. When I released it, it was working quite well. You could upload some files, and voila, they were displayed beneath the comment. But then people requested to be able to display images. So ithcy, jakob and Shino started customizing. I've added their contributions to the extension, but soon people wanted other features: lightbox, thickbox, secure paths, and so on.... In the process I wasn't paying attention anymore to Mark's philosophy: keeping it simple.

The future
So, what's gonna be new about Attachments 2.0? Well, I've started from the ground up and decided to think: how would Mark do it? :P
People want different things with their uploaded files: some want thumbnails, others want to just display the images. And some people want lightbox, and other want to resize images. How can you create an extension with keeping all these wishes in mind?

AttachmentFormatter
Let me introduce the AttachmentFormatter. The Attachment extension will be plain and simple: just an extension to upload files to your comments. Nothing more, nothing less. But here comes the AttachmentFormatter: you will be able to create your own extensions for my extension (still following? :P). The AttachmentFormatter will process files based on their file-extension. This way you can handle files differently. There will be events like: "OnSave", "OnDelete", "OnDisplay", "OnDownload", etc. These Formatters can be selected in the settings tab, just like with normal extensions. This way, the Attachments extension can be everyting you ever wanted :D

Other cool stuff
I've also been thinking about how things were being processed. In Attachments 1 I did a search for files on every comment that was displayed. So 50 comments would start 50 filesystem searches. I've changed that. When the CommentGrid is loaded, it will load the AttachmentManager which will do a search in the uploadpath that's based on the DiscussionID. Storing attachments in a discussion subdir allows the AttachmentManager to get the files much faster. Also, you won't end up with 100,000 files in one folder.

Well... that's it for now. I will keep you posted on how I'm progressing with the development. If you have any suggestions, feel free to add them to this discussion!
«1

Comments

  • Options
    I WAS going to suggest putting the discussion ID in the name along with the user ID, so that I can upload the same file name in two diferent places... but I see you already have a better solution. OnDownload event--I guess that could invoke a download counter? Sweet! *Bows*
  • Options
    OMG! JazzBOT! Come on, man! You must sleep sometimes!
  • Options
    edited July 2006
    Can dependencies be listed between extensions in the add-on library?
  • Options
    MarkMark Vanilla Staff
    @bergamot: not yet. I didn't anticipate this type of thing happening. But I'll add it in there for sure.
  • Options
    will we be able to select if the attachment is to be displayed inline (in the post) or shown below? EG could we upload files and then do something like [attach1 align="left"] Hmm I wonder if that's too hard? how do you determine IF it can be displayed inline, eg PDF vs JPG I guess I'm thinking selfishly ... for my blog version of Vanilla so I can upload post pictures
  • Options
    I'd like to have the "Attach a file" field in the post form hidden, but include a (+) button next to the whisper box that makes it appear (perhaps with a nice smooth javascript slide in effect) after it has slid in, the button should become a (-) or something to hide the form component. To be honest, I think the same could be done for the whisper field, just a little icon (I'm sure there's an appropriate Silk one, if not, I'll make one) that toggles the field. Since both of these fields are used in exceptional cases rather than general use.
  • Options
    bigshow: I did that months ago, but only on my site. It was really easy, though.
  • Options
    Sounds good - so there's going to be add-ons to the add-ons ;-)

    If there are going to be lots of options, I think the simple thumbnail version should be the standard option - low mess and low overhead page loads that don't exclude slower connections.

    Similar to what Wallphone said: is there any sensible way to make attribute images not only to the discussion but also to the user? I'm sure the user gallery wish is somewhere down the line and uploading stuff twice seems unnecessary from a user point of view.

    I'm still running an earlier version before you changed path processing, so I think your simplify-clarify approach is good!!

    If you need a hand anywhere, just say so!
  • Options
    Had another thought this AM... how about some options to limit which categories (and roles) are allowed to have attachments.
  • Options
    I'm with WallPhone! Limits to what roles are eligible to post files would be superb!
  • Options
    I have a slightly off-topic feature wish, but there is a link so keep on reading ;-) What I'd love is a Tab called "Documents", "Files" or something like that. In tech speak, a document repository. The link to Attachments 2.0 is two-fold. Firstly, upload/permissions/db issues could be treated once, within one extension. Secondly, the "Documents" tab could have a folder which "scanned" the forum for attachments - allowing someone to browse the forums attachments without looking through every thread. Whilst I realise this might not be a core focus or feature, I think it could be popular for many Vanilla uses.
  • Options
    Could it be possible for each upload to be renamed so that the user id is placed at the front eg. I upload a file called test.jpg and it's renamed to giginger_test.jpg or something like that anyway. Does that make sense? In a similar vein, different folders for each user who uploads? I assume this could be done with an extension for your extension but I'm at a loss as to how.
  • Options
    Ooh! Thomas' post gave me the idea to give discussions in the disucssion grid an "attached" class if it contains a attachment.

    That way you could style a paperclip icon next to the discussion as appropriate.
  • Options
    Progress on Attachments 2.0 core: 75%
  • Options
    Sweet!

    Is this all you do?
  • Options
    No, I eat and drink to stay alive :)
  • Options
    SLEEP IS FOR THE WEAK!
  • Options
    Ok, the Attachments 2.0 core is about 90% finished, but I'm stuck at determing the upload path. With the new extension, I validate and upload before the discussion is saved. This way I can stop the discussion from being created when the file upload didn't work for whatever reason. However, if the upload does work, I can't save them to a discussion folder because when creating new discussions, the discussionID is 0... When I've figured this out, the rest will be easy and it will soon be completed. Any ideas?
  • Options
    lol run a query that finds out what the last one is and add 1 :P
  • Options
    Upload to a temporary folder and copy to the proper location when the discussion is loaded?
This discussion has been closed.