Updated: Comment #11
Problem/Motivation
Currently only one block is provided by module and limits users to showing posts from their user timeline. Users can not show posts using a certain tag.
Proposed resolution
Create a second block that shows instagram posts related to a certain tag.
Remaining tasks
- Extend request method to handle tag based request
- Create a second block
- [Blocker]Handle configuration storage for multiple blocks
User interface changes
Multiple blocks for different tasks
API changes
None yet...
Original report by @adnasa
Since the drupal client already has an access token, it would be nice
to be able to fetch media based on a tag.
My small solution solves the problem, but may need a bit more cleanup.
- Implemented requestTagMedia on InstagramRequest.class
- Implemented requestUserMedia on InstagramRequest.class
- Added a try/catch since InstagramRequest::request throws an error. ( may need to display a smoother message )
It's been a while since I've been active on do. so be nice when you review the patch :)
---
cheers!
Comments
Comment #1
adnasa commentedThe reason I choose to patch the solution here instead of drupagram, is because drupagram tries to solve more than I
can ask for for this kind of case.
instagram_block does exactly what I want, but needs a "tag" field :)
Comment #2
yanniboi commentedThanks for the patch, I will do some testing and give feedback as soon as I find some time.
Comment #3
yanniboi commentedCool it looks great!
I've made some adjustments to the exception message and added a watchdog.
Other than that, from my point of view, this is good to go in.
Do you need me to release a new version, or are you happy with this just being on 7.x-1.x for a while?
Comment #4
rlmumfordI don't think you need to shorten this everywhere, makes more sense to me as longer.
Whitespace error.
I think here you don't need to worry about drupal_set_message and watchdog - that should all be handled by Drupal's existing error handling. I suggest replacing the two lines in this catch with:
I also don't think you need the \ before Exception as there is no namespacing in Drupal 7 anyway.
Comment #5
yanniboi commentedGreat, thanks @rlmumford.
So I have implemented most of your changes. I wasn't sure about your 'throw $e;' because passing the exception back to drupal's error handling will actually stop the page from loading, and I didn't think that a block not getting the correct response should bring the site down. But then I thought of the different reasons why this exception would happen, and the only reasons I could think of involved developers messing with code (as we don't allow front end users to access the url).
So I've attached a screenshot of the error handling for that exception and I'm happy with it.
Comment #6
yanniboi commentedComment #7
adnasa commentedMan, reading raw diff-files is really making me dizzy.
Anyway, straight down to business
I'm good atm, I just needed this implemented when the task was at hand. I'd like to see that this is a good patch first before we accidentally destroy something :)
Some notes, before we proceed on this.
This presents a little UX problem:
- The tag field is in the same configuration as the configuration for the actual block that is (as intended) to be the block displaying user-media, not tag-media.
A proper solution to this would be separating into a tag-media block, and leave the original block as it is.
Update on the patch coming up.
Another note
- The configuration for the block presents the same configuration fields as the main configuration page. Is there any specific intention to this @yanniboi?
If not, I think we should consider removing the block configuration fields but we'll tackle that in another issue.
Comment #8
yanniboi commentedNo I've been thinking about that for a while. I think that there should be module specific settings and block specific settings. However because there was always just one block I didn't worry much about separating them. I also think that a block type with unlimited instances (eg like custom blocks, menu blocks, twitter blocks, etc.) is beyond the scope of this module.
I think that providing two blocks, one for user related, one for tag related, would work. However if we end up having more than two we might need to rethink that approach.
In short I think you are right. Lets add another block in this issue, and start another issue for fixing the settings.
Comment #9
adnasa commentedAbsolutely, let's call it progress for now :)
Here is a patch, perhaps you didn't think I was too crazy.
I think we should take one step at a time. If the time comes that I would need that, be sure that I'd be back with a bit more patches (if time allows)
Updates in the patch:
- Implemented tag block
- Updated configuration page with tag field
- Tested only through the UI for the moment.
Comment #10
adnasa commented@yanniboi, any thoughts?
Comment #11
yanniboi commentedBeen away this weekend, but having a look at this tonight.
First thoughts include:
Changing the original block's name breaks backward compatibility.
Not entirely happy with the way config works in the light of having multiple blocks.
I think I am going to add a blocker issue. If we are going to have multiple blocks then the config really needs sorting out. I will open another issue to fix config, get that patch in first and then rebase the work we are doing here.
Hopefully I'll have made some good progress by the end of the night.
Comment #12
yanniboi commentedUpdated issue summary
Comment #13
yanniboi commentedI have rebased your last patch on top of the first patch on #2197905: Block config and module config should be stored separately. I only updated it with respect to necessary changes in light of the new commit it is applied on top.
The next patch will be my changes on top of your changes and I think at this point an interdiff will be due.
Comment #14
yanniboi commentedAnd here is my patch! Wow, long night!
I have renamed the block deltas to maintain backward compatibility, I have refactored the block config forms (not really that tidy, but it works) and I now pass $values and $config to the InstagramRequest constructor as they are stored in separate values.
Have a look and see what you think...
Comment #15
yanniboi commentedWhile reviewing this patch I found some errors in the config page links...
Comment #16
yanniboi commentedI've reviewed this patch and am committing it.
Comment #18
yanniboi commented