mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Adding order to statistics/feedback.
This commit is contained in:
parent
53709975fc
commit
38ab573ba6
5 changed files with 15737 additions and 15608 deletions
|
@ -117,11 +117,13 @@ class MFeedback(mongo.Document):
|
|||
subject = mongo.StringField()
|
||||
url = mongo.StringField()
|
||||
style = mongo.StringField()
|
||||
order = mongo.IntField()
|
||||
|
||||
meta = {
|
||||
'collection': 'feedback',
|
||||
'allow_inheritance': False,
|
||||
'indexes': ['style'],
|
||||
'ordering': ['order'],
|
||||
}
|
||||
|
||||
def __unicode__(self):
|
||||
|
@ -131,9 +133,12 @@ class MFeedback(mongo.Document):
|
|||
def collect_feedback(cls):
|
||||
data = urllib2.urlopen('https://getsatisfaction.com/newsblur/topics.widget').read()
|
||||
data = json.decode(data[1:-1])
|
||||
i = 0
|
||||
if len(data):
|
||||
cls.objects.delete()
|
||||
for feedback in data:
|
||||
feedback['order'] = i
|
||||
i += 1
|
||||
for removal in ['about', 'less than']:
|
||||
if removal in feedback['date']:
|
||||
feedback['date'] = feedback['date'].replace(removal, '')
|
||||
|
|
|
@ -57,7 +57,9 @@
|
|||
- (void)setTitle:(NSString *)title;
|
||||
- (void)showOriginalStory:(NSURL *)url;
|
||||
- (void)closeOriginalStory;
|
||||
- (int)indexOfNextStoryInDirection:(NSInteger)direction;
|
||||
- (int)indexOfNextStory;
|
||||
- (int)indexOfPreviousStory;
|
||||
- (int)indexOfActiveStory;
|
||||
+ (int)computeStoryScore:(NSDictionary *)intelligence;
|
||||
|
||||
@end
|
||||
|
|
|
@ -119,12 +119,39 @@
|
|||
[originalStoryViewController dismissModalViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (int)indexOfNextStoryInDirection:(NSInteger)direction {
|
||||
for (int i=0; i < [activeFeedStories count]; i++) {
|
||||
if ([activeStory objectForKey:@"id"] == [[activeFeedStories objectAtIndex:i] objectForKey:@"id"]) {
|
||||
return i + direction;
|
||||
- (int)indexOfNextStory {
|
||||
int activeIndex = [self indexOfActiveStory];
|
||||
int activeFeedStoriesCount = [activeFeedStories count];
|
||||
NSLog(@"ActiveStory: %@: %@", activeIndex, activeFeedStoriesCount);
|
||||
for (int i=activeIndex+1; i < activeFeedStoriesCount; i++) {
|
||||
NSDictionary *story = [activeFeedStories objectAtIndex:i];
|
||||
if ([story objectForKey:@"read_status"] == 1) {
|
||||
NSLog(@"NextStory: %@", i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (int)indexOfPreviousStory {
|
||||
NSInteger activeIndex = [self indexOfActiveStory];
|
||||
for (int i=activeIndex-1; i >= 0; i--) {
|
||||
NSDictionary *story = [activeFeedStories objectAtIndex:i];
|
||||
if ([story objectForKey:@"read_status"] == 1) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (int)indexOfActiveStory {
|
||||
for (int i=0; i < [activeFeedStories count]; i++) {
|
||||
NSDictionary *story = [activeFeedStories objectAtIndex:i];
|
||||
if ([activeStory objectForKey:@"id"] == [story objectForKey:@"id"]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ (int)computeStoryScore:(NSDictionary *)intelligence {
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
|
||||
- (void)showStory {
|
||||
NSLog(@"Loaded Story view: %@", appDelegate.activeStory);
|
||||
// NSLog(@"Loaded Story view: %@", appDelegate.activeStory);
|
||||
NSString *imgCssString = [NSString stringWithFormat:@"<style>"
|
||||
"body {"
|
||||
" line-height: 18px;"
|
||||
|
@ -150,7 +150,6 @@
|
|||
if ([appDelegate.activeStory objectForKey:@"story_authors"]) {
|
||||
NSString *author = [NSString stringWithFormat:@"%@",[appDelegate.activeStory objectForKey:@"story_authors"]];
|
||||
if (author && ![author isEqualToString:@"<null>"]) {
|
||||
NSLog(@"Author: %@ Length: %d",author, [author length]);
|
||||
story_author = [NSString stringWithFormat:@"<div class=\"NB-story-author\">%@</div>",author];
|
||||
}
|
||||
}
|
||||
|
@ -183,15 +182,35 @@
|
|||
}
|
||||
|
||||
- (IBAction)doNextUnreadStory {
|
||||
NSInteger nextIndex = [appDelegate indexOfNextStoryInDirection:1];
|
||||
[appDelegate setActiveStory:[[appDelegate activeFeedStories] objectAtIndex:nextIndex]];
|
||||
[self showStory];
|
||||
int nextIndex = [appDelegate indexOfNextStory];
|
||||
if (nextIndex == -1) {
|
||||
|
||||
} else {
|
||||
[appDelegate setActiveStory:[[appDelegate activeFeedStories] objectAtIndex:nextIndex]];
|
||||
[self showStory];
|
||||
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:.5];
|
||||
[UIView setAnimationBeginsFromCurrentState:NO];
|
||||
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)doPreviousStory {
|
||||
NSInteger nextIndex = [appDelegate indexOfNextStoryInDirection:-1];
|
||||
[appDelegate setActiveStory:[[appDelegate activeFeedStories] objectAtIndex:nextIndex]];
|
||||
[self showStory];
|
||||
NSInteger nextIndex = [appDelegate indexOfPreviousStory];
|
||||
if (nextIndex == -1) {
|
||||
|
||||
} else {
|
||||
[appDelegate setActiveStory:[[appDelegate activeFeedStories] objectAtIndex:nextIndex]];
|
||||
[self showStory];
|
||||
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:.5];
|
||||
[UIView setAnimationBeginsFromCurrentState:NO];
|
||||
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:NO];
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showOriginalSubview:(id)sender {
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue