Feature #2757
closedCreate "Download All" Capabilities for Files in a Folder
Added by Matt Gold about 11 years ago. Updated about 10 years ago.
0%
Description
Just looking at a group whose members need to download a bunch of PDFs in a folder. Would be useful to have the ability to download all files at once rather than clicking on each one individually.
Files
download-icon.png (5.39 KB) download-icon.png | Chris Stein, 2014-08-04 03:41 PM | ||
upload-arrow.png (6.74 KB) upload-arrow.png | Chris Stein, 2014-08-04 03:41 PM | ||
download-arrow.png (4.58 KB) download-arrow.png | Chris Stein, 2014-08-04 03:41 PM | ||
upload-icon.png (3.73 KB) upload-icon.png | Chris Stein, 2014-08-04 03:41 PM | ||
download-all-button.png (60.1 KB) download-all-button.png | Chris Stein, 2014-08-04 03:41 PM | ||
folder-download-v1.png (59.7 KB) folder-download-v1.png | Chris Stein, 2014-08-04 03:41 PM | ||
folder-download-v2.png (59.1 KB) folder-download-v2.png | Chris Stein, 2014-08-04 03:41 PM | ||
Selection_001.bmp (1.19 MB) Selection_001.bmp | Daniel Jones, 2014-09-23 04:15 PM | ||
Download-under-show.png (13.6 KB) Download-under-show.png | Chris Stein, 2014-09-28 08:18 PM |
Updated by Boone Gorges about 11 years ago
- Status changed from Assigned to Reporter Feedback
Does "folder" mean the folderish tags that appear in the Files subsection of a group?
Updated by Boone Gorges about 11 years ago
- Status changed from Reporter Feedback to Assigned
- Assignee changed from Boone Gorges to Dominic Giglio
- Target version set to 1.6
Dom, will you look into this? A link that assembles a zip file on the fly from the files currently displayed, and forces a download for the user.
Updated by Boone Gorges about 11 years ago
Thanks. I've put it into the 1.6 milestone, so no need to drop everything.
Updated by Boone Gorges almost 11 years ago
- Category name changed from BuddyPress (misc) to Group Files
Updated by Boone Gorges over 10 years ago
- Target version changed from 1.6 to 1.7
Updated by Matt Gold over 10 years ago
- Due date set to 2014-05-02
Dom, can you please give us an update on this by next Friday, May 2? Thank you
Updated by Dominic Giglio over 10 years ago
Yes sir, I'll have a look this weekend and reply with an update on what I think we can do.
Updated by Boone Gorges over 10 years ago
- Assignee changed from Dominic Giglio to Daniel Jones
Reassigning this over to Dan for the time being. Dan, the plugin that we use for group files is wp-content/plugins/buddypress-group-documents. That plugin is an old fork of an abandoned plugin. So, when you're exploring how to do this, if you need to make mods to the plugin itself, you may. Though, in general, we do try to avoid that; it's likely that for this kind of standalone functionality, you'll be able to manage with a couple of add_action()
calls. For these kinds of things, check out the file wp-content/plugins/cac-bp-custom-includes/group-documents.php, where there are other miscellaneous mods to the way the plugin works.
Basically, your strategy will be http://redmine.gc.cuny.edu/issues/2757#note-3. More specifically, you'll probably need two different functions:
1. Something that creates the necessary markup for the link in the interface. Use whatever format for the link you want; something like <a href="http://commons.gc.cuny.edu/groups/groupname/files?download=all"> makes sense to me (use bp_get_group_permalink()
to get a group URL dynamically).
2. A request catcher. I suggest the following format. Hooking to the 'bp_actions' hook will let you send content to the browser (ie, the zip file) before WP sends any other headers.
function cac_group_files_download_all_request() { // Make sure that this is a download=all request if ( empty( $_GET['download'] ) || 'all' !== $_GET['download'] ) { return; } // Probably also wise to do a permissions check - make sure the user is a member of the group for non-public groups // A nonce check is probably also a good idea. // do your magic - Check out http://davidwalsh.name/create-zip-php for a simple tutorial on creating zips, and check out the buddypress-group-documents source to see how to pull up a list of documents for the group } add_action( 'bp_actions', 'cac_group_files_download_all_request' );
Hopefully that's enough to get you started. Please let me know if you hit snags or need more direction.
Updated by Daniel Jones over 10 years ago
I think I've got this working. Change set is at https://github.com/cuny-academic-commons/cac/commit/de5fe5e5433fdf2fc858c0ee2d85df0a9473896f
I added functions to /cac-bp-custom-includes/group-documents.php as Boone Suggested, and modified the cac_group_documents_display_content() function to display the button and generate the link, which is also along the lines Boone suggested. I ended up adding a 'download' query var as well.
One function I added that might be useful in the future is get_group_file_paths(), which takes a group ID and returns an array of the absolute paths to the group's files.
To make the Download All button consistent with the CSS and Javascript for the Upload File button, I had to make some changes to a couple other files from the original plugin and from the bp-nelo theme.
Updated by Boone Gorges over 10 years ago
Hey Dan - this is looking pretty good. Thanks for your work so far! Couple comments:
- I'm hitting a fatal error running it: listDirectory()
is not a function. You must have defined this somewhere else? As a side note, I'm not 100% sure why this bit is necessary - does buddypress-group-documents ever create nested folders inside of BP_GROUP_DOCUMENTS_SECURE_PATH . $group_id . '/'
?
- It's good to use nonces here, but it's more secure to pass some unique identifier along to them. Try: wp_nonce_url( $whatever, 'cac-download-all-files' )
and then wp_verify_nonce( $nonce, 'cac-download-all-files' )
See http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/
- Building these zips is sorta processor intensive, so we should probably not allow non-logged-in visitors to do it (especially crawlers). Can you please hide the Download All button (and bail out of cac_group_files_download_all_request()
) if ( ! is_user_logged_in() )
?
Small niggles:
- Please prefix function names to ensure uniqueness. Eg cac_add_download_query_arg()
.
- Consistent indentation and whitespace would make it a bit easier to read. For CAC/WP projects, please set your editor to use true tabs.
Updated by Daniel Jones over 10 years ago
Thank Boone! I made the all changes you suggested. Change set is at https://github.com/cuny-academic-commons/cac/commit/729a02354ecd7f9e07d8b4ce14d99ec8bf528fe3
Updated by Boone Gorges over 10 years ago
- Assignee changed from Daniel Jones to Chris Stein
Thanks, Dan! This is looking great.
I've pulled the changes to cdev for testing. Chris, please have a look at button placement here: http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/ Let me know whether you think this is the right UI for the job. (Never mind the fact that the zip doesn't contain all the files - the group document directory on cdev is out of date, and I'm having a hard time running an update script at the moment because of permissions issues).
Updated by Chris Stein over 10 years ago
- File download-icon.png download-icon.png added
- File upload-arrow.png upload-arrow.png added
- File download-arrow.png download-arrow.png added
- File upload-icon.png upload-icon.png added
- File download-all-button.png download-all-button.png added
- File folder-download-v1.png folder-download-v1.png added
- File folder-download-v2.png folder-download-v2.png added
The placement is OK but I overlooked it at first. A couple of suggestions that could be made independently or together:
1. Icons
Now that we have more than one button it would be nice to do something to visually separate them. Up and down arrow icons seem appropriate. I don't know if we have these in our current icon set (do we have a defined set?). I'm attaching a couple of examples (file names with arrow or icon).
2. Change Placement
Another idea is to move the download button to where we say how many files there are. On a related note I noticed that on the main files page it doesn't give a list of the number of files, but when you go into a folder it does list the number of files.
I have attached a few screenshots:
download-all-button.png shows the download for the main files page. I had to add in the text "Viewing item 1 to 20 (of 25 items)."
I also added in text below it "Click on a filename to download it." That was added just because I realized that not everyone might understand you just have to click the filename to download it (and because that same action produces a different result in the docs area).
Question: are you able to "download all" for folders too or just all files? The button wasn't working for me on cdev.
The other two images are if we have a download button for the folder files as well.
folder-download-v1.png this has basically the same interface as the download-all-button.png and is done to keep them consistent.
folder-download-v2.png In this case I moved the button to be close to the name of the folder. The reasoning here would be that being next to the name of the folder it is clear what it is for.
Updated by Boone Gorges about 10 years ago
Chris, apologies that we haven't responded here - I think you left your update during a period of downtime for Redmine email notifications.
Your feedback here is helpful. I agree that the button placement and visuals could be improved.
We don't have a standard set of icons for the Commons, but an increasing number of plugins and themes are adopting Genericons, so I suggest we do the same. We could use the "cloud-download" item: http://genericons.com/#cloud-download Chris, does that seem OK to you?
If so, I suggest we make the following changes from what's currently in place:
- Change "Download all files" to a text link rather than a button
- Add the cloud-download Genericon icon
- Move it to this position: http://redmine.gc.cuny.edu/attachments/download/1317/folder-download-v1.png (The folder ones are nice, but what Dan has built does not currently support downloading all items in a folder.)
Does that work for everyone?
Updated by Chris Stein about 10 years ago
That works for me, I think the icon with the text and the new placement makes things clear (I'm not sold on whether people understand cloud icons in general but with the text in this context I think it's fine).
Updated by Boone Gorges about 10 years ago
- Assignee changed from Chris Stein to Daniel Jones
Dan, reassigning to you to implement what I've laid out here: http://redmine.gc.cuny.edu/issues/2757#note-18
Updated by Boone Gorges about 10 years ago
Hi Dan - Please update this ticket to let me know if you'll be able to make the requested changes in the next few days. This feature is close enough to done that I'll finish it myself if you won't be able to get to it by, say, this time next week. Thanks!
Updated by Daniel Jones about 10 years ago
- File Selection_001.bmp Selection_001.bmp added
Sorry for the delay on this - I made the changes you laid out, Boone, but I did run into one problem so I havent committed them and pushed them up yet. The version of Group Files I have doesn't look exactly like what you have in your screen shot - mine doesn't have the information about how many files there are and how many are being viewed, or the message about clicking on a file name to download. I've attached a screenshot of what the section of the page looks like for me, with the changes made as best as I could. What do you think I should do next?
Updated by Daniel Jones about 10 years ago
Oh I guess we were updating the ticket at the same time!
Updated by Boone Gorges about 10 years ago
Thanks, Dan - It looks like that pagination stuff only shows up when looking at a Folder. Try adding a file or two to a folder and then clicking the folder name. IMO this is a bug - the pagination should always show up. Could you look at this?
Updated by Daniel Jones about 10 years ago
Okay sounds good I'll see how that looks. Sure thing I'll see if I can the pagination to show up on the group files home screen. Thanks Boone!
Updated by Daniel Jones about 10 years ago
I think I've implemented what we're looking for here. Changeset at https://github.com/cuny-academic-commons/cac/commit/e48a00eac2f892d98b92fe2892b9ba6d1506805c
The problem with the pagination was that it relied on a variable "$has_items" that relied on a $template->category being set, which is only true for folders. So I added an else statement to that part of the code that sets $has_items to true if there's no category but the $template->document_list isn't empty. Is that alright?
I wasn't 100% sure where to store the genericons font but I thought the closer to the stylesheet it's referenced in the better, so I put it in its own subfolder the _inc folder in the bp_nelo theme. Shouldn't be too hard to move it though. Also had to modify some js and css to reflect the fact that the download all link is a link now and not a button. Let me know if I should make any more changes, and again I'm really sorry about the delay on this.
Updated by Boone Gorges about 10 years ago
- Status changed from Assigned to Testing Required
- Assignee changed from Daniel Jones to Chris Stein
Thanks, Dan! Implementation of Genericons looks just fine for the time being. (If we start using them more, we should have drop-in class names for them.)
Your fix for the pagination bug looks good too. Thanks!
Styling on the link feels a little off to me. I feel like it should be a bit closer to the size of the pagination, and ideally the text would be vertically centered on the icon. I think this is hard to do given that you've put the genericon on the :before of the link itself - it'd be easier if you put it on a separate element that could be positioned separately. (In the past, I've used something like:
<i class="genericon genericon-cloud" />.)
For now, in the interest of moving on with our lives, I'm going to reassign this to Chris for some visual feedback. Chris, this is ready to have a look at on cdev. If you have any suggestions for final visual tweaks, that'd be great - or give us the go-ahead to close this ticket. Thanks!
Updated by Chris Stein about 10 years ago
- File Download-under-show.png Download-under-show.png added
Boone, I agree that it would be nice to have the download link be aligned with the "viewing item.." and pagination link. As for putting it in a separate element or the :before pseudo it can work either way. If you change the :before to a block then it can be easier to position it around (http://www.smashingmagazine.com/2011/07/13/learning-to-use-the-before-and-after-pseudo-elements-in-css/ ).
I do have a question and one more possible change to the positioning depending on the answer. When you're in a folder does the link just download the files in the folder or still all of the files? If it is all of the files then we might want to move the link under Show All Files (attache image). The reason is that it might be confusing to see "Viewing item 1 to 9 (of 9 items)" and then the download link right next to it downloads more than those 9 files. The link does say "all group files" but I'm wondering if people won't really read that or understand it. Placing the link next to Show All Files may be clearer (I moved the icon to the right just because it seemed to look better with the text aligned on the left).
Updated by Chris Stein about 10 years ago
- Assignee changed from Chris Stein to Daniel Jones
Dan, I forgot to add at the end that in the interest of getting this out I'm OK with leaving the final visual tweaks and placement up to you (based on the feedback). If you have any questions, I'm happy to answer, if you want to get this done and out that's fine. Giving it back to you.
Updated by Matt Gold about 10 years ago
I agree with Chris that the icon should be over to the right with the "viewing item info + pagination link."
Can we look at some options for the icon? I'm not especially happy with this one and would like us to look at a few possibilities.
Chris's question about whether we're downloading all group files or only those in a particular folder when looking that folder is a good one. My preference would be to have multiple functionalities:
-- on the "show all" files homepage ( http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/?category=0 ), to have the ability to download all group files
-- on the page of a particular folder, to have the option to download all of the items in that folder
Updated by Boone Gorges about 10 years ago
Dan, correct me if I'm wrong, but I believe the current functionality is to download all group files, regardless if you're looking at a folder. I take Chris's point that this suggests that putting the link right next to the folder filter is probably not a great experience. Matt, it would be nice to have the more fine-grained functionality, but given the timeline I'm going to suggest that we leave the functionality as-is for 1.7 and open another ticket for the more sophisticated tool.
Can we look at some options for the icon? I'm not especially happy with this one and would like us to look at a few possibilities.
I'd be fine with looking at more options, but please note that technically it is not trivial to swap the icon out, so any decisions should be made in the next day or two. Please also note that the option we're currently using is licensed properly for our use on the Commons, so any other options will have to be licensed as such as well (non-commercial use licenses are fine, but GPL-compatible licenses are better if we ever plan to distribute this). Given these considerations, perhaps Chris could make suggestions?
Updated by Matt Gold about 10 years ago
FWIW, the download all link isn't actually working for me on CDEV. Does it preserve file structures when downloading files?
Updated by Boone Gorges about 10 years ago
Matt - Can you clarify what you mean by "the download all link isn't actually working for me"? From http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/, I click "Download all group files" and a zip file is downloaded to my computer. Note that the link is, by design, only visible to logged-in users.
Does it preserve file structures when downloading files?
I assume you're talking here about folders, right? No, not at this time.
Updated by Chris Stein about 10 years ago
Matt, I couldn't reproduce the download error either.
For an alternative icon what about the "fa-download" or one of the arrow down icons from Font Awesome: http://fortawesome.github.io/Font-Awesome/icons/
They are Compatible with GPL and there are a lot so we could potentially use them throughout the site.
Updated by Boone Gorges about 10 years ago
- Assignee changed from Daniel Jones to Boone Gorges
In the interest of our upcoming deadline, I've decided to do some cleanup here myself. https://github.com/cuny-academic-commons/cac/commit/b7b6f10024edecbcd89fe4c7d5d8da65bb1a1c3f
1. I moved the link to the upper right, where it's set apart from other stuff http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/
2. Added the ability to download folder-specific stuff. When viewing a specific folder, you'll see a "This folder" link http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/?category=52260
3. Downloading "all files" will create a zip with folder organization
Ready to test on cdev
Updated by Boone Gorges about 10 years ago
- Status changed from Testing Required to Resolved
Thanks for all your work on it, Dan! Together we built something kinda neat :)
I showed the latest UI to Matt in person during a meeting today. He gave us the green light with the current implementation (though he's still not a huge fan of the icon, it's less prominent now, and it's good enough for 1.7). If there are issues that block 1.7, feel free to reopen this ticket, or open a new one against the milestone. Other enhancements should go into new tickets. Thanks!
Updated by Matt Gold about 10 years ago
Thanks to you both for your great work on this.
Updated by Daniel Jones about 10 years ago
Thanks Matt and Boone! It was really great to work on it - I had never really worked with creating .zip archives on the fly before. Sorry I wasn't able to 100% follow through on it, but it was great to get to review your added code for folder support, Boone. Thanks again.
Updated by Chris Stein about 10 years ago
Adding in my thanks to both of you too. I'm hoping to get my department on the site and have files up there so this will come in handy!
Updated by Sarah Morgano about 10 years ago
- Status changed from Resolved to Reporter Feedback
I just tried to download all the files from our community team group and it wouldn't work for me, it just refreshes the page.
Updated by Matt Gold about 10 years ago
- Status changed from Reporter Feedback to Assigned
Updated by Boone Gorges about 10 years ago
- Status changed from Assigned to Testing Required
Thanks, Sarah. Turns out this is not due to a problem with the new functionality, but with cdev - the list of files you were seeing on this page http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/ didn't actually reflect the files in the relevant upload folder on the server. I spent a bunch of time today doing a full sync of bp-group-documents content from commons to cdev, but I hit some lame technical snags, so I've given up. For the time being, I have manually moved over the files for http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/documents/, so at least you can test the zip download now. (It will also work with any new documents you upload to any group.) Please test and report back.
Updated by Boone Gorges about 10 years ago
- Status changed from Testing Required to Resolved
Hi Sarah - Going to close this one as resolved, to clear the milestone. If you continue to see issues, please let me know.