Skip to content

Commit

Permalink
Merge branch 'master' into discover
Browse files Browse the repository at this point in the history
* master:
  Postgres secondary
  Prometheus 500GB data.
  New forum server.
  Adding youtube feeds to PuSH.
  Adding macOS screenshots.
  Updating ansible setup.
  #1890 (Add Auto to theme selector)
  #1247 (Mac Catalyst edition)
  Fixed a feed detail swipe starting on one row and ending on another causing the wrong row being marked unread
  Prep
  • Loading branch information
samuelclay committed Oct 11, 2024
2 parents 8740c9a + cf9f0d9 commit abeb3d4
Show file tree
Hide file tree
Showing 35 changed files with 276 additions and 187 deletions.
25 changes: 12 additions & 13 deletions ansible/env_vars/base.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

github_directory: github.com/samuelclay/newsblur
git_web_repo: ssh://git@{{ github_directory }}
git_secrets_repo: ssh://[email protected]/samuelclay/newsblur-secrets
Expand All @@ -17,16 +16,16 @@ sentry_task_release_webhook: "{{ lookup('ini', 'task_release_webhook section=sen
sentry_monitor_release_webhook: "{{ lookup('ini', 'monitor_release_webhook section=sentry file=/srv/secrets-newsblur/configs/sentry.ini') }}"
sentry_node_release_webhook: "{{ lookup('ini', 'node_release_webhook section=sentry file=/srv/secrets-newsblur/configs/sentry.ini') }}"

sys_packages: [
'git',
'python3',
'python3-dev',
'zsh',
'openssl',
'libssl-dev',
'libssl-doc',
'build-essential',
'ntp',
'htop'
]
sys_packages:
[
"git",
"python3",
"python3-dev",
"zsh",
"openssl",
"libssl-dev",
"libssl-doc",
"build-essential",
"htop",
]
grafana_password: "{{ lookup('ini', 'grafana_password section=grafana file=/srv/secrets-newsblur/configs/grafana.ini') }}"
6 changes: 3 additions & 3 deletions ansible/inventories/digital_ocean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugin: constructed
strict: False

groups:

haproxy: inventory_hostname.startswith('www')

web: inventory_hostname.startswith('app')
Expand All @@ -12,6 +11,7 @@ groups:
counts: inventory_hostname.startswith('app-counts')
push: inventory_hostname.startswith('app-push')
blogs: inventory_hostname.startswith('blog')
forum: inventory_hostname.startswith('forum')

node: inventory_hostname.startswith('node')
node_socket: inventory_hostname.startswith('node-socket')
Expand All @@ -25,9 +25,9 @@ groups:
task: inventory_hostname.startswith('task')
celery: inventory_hostname.startswith('task-celery')
work: inventory_hostname.startswith('task-work')

staging: inventory_hostname.startswith('staging')

db: inventory_hostname.startswith('db')
search: inventory_hostname.startswith('db-elasticsearch')
elasticsearch: inventory_hostname.startswith('db-elasticsearch')
Expand Down
8 changes: 4 additions & 4 deletions ansible/inventories/hetzner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ plugin: constructed
strict: False

groups:

hall: inventory_hostname.startswith('h')

haproxy: inventory_hostname.startswith('hwww')

app: inventory_hostname.startswith('happ')
Expand All @@ -20,6 +19,7 @@ groups:
push: inventory_hostname.startswith('happ-push')
hpush: inventory_hostname.startswith('happ-push')
blogs: inventory_hostname.startswith('blog')
forum: inventory_hostname.startswith('hforum')

node: inventory_hostname.startswith('hnode')
hnode: inventory_hostname.startswith('hnode')
Expand All @@ -40,9 +40,9 @@ groups:
task: inventory_hostname.startswith('htask')
celery: inventory_hostname.startswith('htask-celery')
work: inventory_hostname.startswith('htask-work')

staging: inventory_hostname.startswith('hstaging')

hdb: inventory_hostname.startswith('hdb')
db: inventory_hostname.startswith('hdb')
search: inventory_hostname.startswith('hdb-elasticsearch')
Expand Down
24 changes: 12 additions & 12 deletions ansible/playbooks/setup_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
vars:
- update_apt_cache: yes
- motd_role: app

roles:
- {role: 'base', tags: 'base'}
- {role: 'ufw', tags: 'ufw'}
- {role: 'docker', tags: 'docker'}
- {role: 'repo', tags: ['repo', 'pull']}
- {role: 'dnsmasq', tags: 'dnsmasq'}
- {role: 'consul', tags: 'consul'}
- {role: 'consul-client', tags: 'consul'}
- {role: 'web', tags: 'web'}
- {role: 'nginx', tags: 'nginx'}
- {role: 'node-exporter', tags: ['node-exporter', 'metrics']}
- { role: "base", tags: "base" }
- { role: "ufw", tags: "ufw" }
- { role: "docker", tags: "docker" }
- { role: "repo", tags: ["repo", "pull"] }
- { role: "dnsmasq", tags: "dnsmasq" }
- { role: "consul", tags: "consul" }
- { role: "consul-client", tags: "consul" }

- { role: "web", tags: "web" }
- { role: "nginx", tags: "nginx" }
- { role: "node-exporter", tags: ["node-exporter", "metrics"] }
20 changes: 20 additions & 0 deletions ansible/playbooks/setup_forum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: SETUP -> forum containers
hosts: forum
vars_files:
- ../env_vars/base.yml
vars:
- update_apt_cache: yes
- motd_role: app

roles:
- { role: "base", tags: "base" }
- { role: "ufw", tags: "ufw" }
- { role: "docker", tags: "docker" }
- { role: "repo", tags: ["repo", "pull"] }
- { role: "dnsmasq", tags: "dnsmasq" }
- { role: "consul", tags: "consul" }
- { role: "consul-client", tags: "consul" }

- { role: "forum", tags: "forum" }
- { role: "node-exporter", tags: ["node-exporter", "metrics"] }
16 changes: 8 additions & 8 deletions ansible/playbooks/setup_metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
- motd_role: db

roles:
# - {role: 'base', tags: 'base'}
# - {role: 'ufw', tags: 'ufw'}
# - {role: 'docker', tags: 'docker'}
# - {role: 'repo', tags: ['repo', 'pull']}
# - {role: 'dnsmasq', tags: 'dnsmasq'}
# - {role: 'consul', tags: 'consul'}
# - {role: 'consul-client', tags: 'consul'}
# - {role: 'mongo-exporter', tags: 'mongo-exporter'}
- { role: "base", tags: "base" }
- { role: "ufw", tags: "ufw" }
- { role: "docker", tags: "docker" }
- { role: "repo", tags: ["repo", "pull"] }
- { role: "dnsmasq", tags: "dnsmasq" }
- { role: "consul", tags: "consul" }
- { role: "consul-client", tags: "consul" }
- { role: "mongo-exporter", tags: "mongo-exporter" }
- { role: "postgres-exporter", tags: "postgres-exporter" }
- { role: "redis-exporter", tags: "redis-exporter" }
- { role: "node-exporter", tags: ["node-exporter", "metrics"] }
Expand Down
4 changes: 2 additions & 2 deletions ansible/roles/consul/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
run_once: yes
become: no
register: consul_manager_ip
local_action: command /srv/newsblur/ansible/roles/consul/tasks/get_consul_manager_ip.py
local_action: command ~/.virtualenvs/newsblur/bin/python /srv/newsblur/ansible/roles/consul/tasks/get_consul_manager_ip.py

- name: Found consul manager IP
debug:
msg: "IP is {{ consul_manager_ip.stdout }}"

- name: Ensure /etc/consul.d exists
become: yes
file:
Expand Down
11 changes: 11 additions & 0 deletions ansible/roles/forum/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: restart discourse
become: yes
docker_container:
name: discourse
state: restarted

- name: reload ufw
become: yes
service:
name: ufw
state: reloaded
20 changes: 20 additions & 0 deletions ansible/roles/forum/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Register forum in consul
tags: consul
become: yes
template:
src: consul_service.json
dest: /etc/consul.d/forum.json
when: disable_consul_services_ie_staging is not defined
notify:
- reload consul

- name: Allow http
become: yes
ufw: rule=allow port=80
tags: ufw

- name: Allow https
become: yes
ufw: rule=allow port=443
tags: ufw
10 changes: 10 additions & 0 deletions ansible/roles/forum/templates/consul_service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"service": {
"name": "{{ inventory_hostname|regex_replace('\d+', '') }}",
"id": "{{ inventory_hostname }}",
"tags": [
"forum"
],
"port": 80
}
}
5 changes: 2 additions & 3 deletions ansible/roles/prometheus/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Template file for prometheus
vars:
monitor_server: "{{ 'staging.newsblur.com' if disable_consul_services_ie_staging is defined else 'newsblur.com' }}"
Expand Down Expand Up @@ -27,12 +26,12 @@
user: root
networks_cli_compatible: yes
network_mode: default
command: --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention.time=10y
command: --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --storage.tsdb.retention.time=10y --storage.tsdb.retention.size=500GB
networks:
- name: newsblurnet
state: started
ports:
- 9090:9090
- 9090:9090
restart_policy: unless-stopped
container_default_behavior: no_defaults
volumes:
Expand Down
21 changes: 10 additions & 11 deletions ansible/roles/ufw/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---

- name: Set hosts
set_fact:
hetzner_hosts: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
do_hosts: "{{ groups['NewsBlur_Docker'] | map('extract', hostvars, ['ansible_host']) }}"

- name: Generate UFW batch script
become: yes
template:
src: ufw_rules.sh.j2
dest: /tmp/ufw_rules.sh
mode: '0755'
mode: "0755"

# - name: Stop ufw and delete all rules
# become: yes
# ufw: state=reset
Expand Down Expand Up @@ -51,14 +50,14 @@
# tags:
# - firewall
# - ufw

# - name: Allow all access from Hetzner inventory hosts
# become: yes
# ufw:
# rule: allow
# src: '{{ item }}'
# with_items: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
# tags:
# tags:
# - firewall
# - ufw
# - hetzner_firewall
Expand All @@ -71,7 +70,7 @@
# route: yes
# src: '{{ item }}'
# with_items: "{{ groups['hall'] | map('extract', hostvars, ['ansible_host']) }}"
# tags:
# tags:
# - firewall
# - ufw
# - hetzner_firewall
Expand All @@ -84,7 +83,7 @@
# src: '{{ item }}'
# with_items: "{{ groups['oldandnew'] | map('extract', hostvars, ['ansible_host']) }}"
# when: "'oldandnew' in groups"
# tags:
# tags:
# - firewall
# - ufw

Expand All @@ -95,7 +94,7 @@
# src: '{{ item }}'
# with_items: "{{ groups['NewsBlur_Docker'] | map('extract', hostvars, ['ansible_host']) }}"
# when: "'oldandnew' not in groups"
# tags:
# tags:
# - firewall
# - ufw

Expand All @@ -107,7 +106,7 @@
# src: '{{ item }}'
# with_items: "{{ groups['NewsBlur_Docker'] | map('extract', hostvars, ['ansible_host']) }}"
# when: "'oldandnew' not in groups"
# tags:
# tags:
# - firewall
# - ufw

Expand Down Expand Up @@ -145,7 +144,7 @@
COMMIT
# END UFW AND DOCKER
tags: docker
tags: docker ufw
notify: restart ufw

- name: Start ufw
Expand Down
2 changes: 2 additions & 0 deletions ansible/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
when: "'app' in group_names"
- import_playbook: playbooks/setup_blog.yml
when: "'blogs' in group_names"
- import_playbook: playbooks/setup_forum.yml
when: "'forum' in group_names"
- import_playbook: playbooks/setup_www.yml
when: "'haproxy' in group_names"
- import_playbook: playbooks/setup_node.yml
Expand Down
23 changes: 13 additions & 10 deletions clients/ios/Classes/FeedDetailObjCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ @interface FeedDetailObjCViewController ()
@property (nonatomic) BOOL isFadingTable;
@property (nonatomic, strong) NSString *restoringFolder;
@property (nonatomic, strong) NSString *restoringFeedID;
@property (nonatomic) NSIndexPath *swipingIndexPath;

@end

Expand Down Expand Up @@ -2237,7 +2238,10 @@ - (NSIndexPath *)indexPathForStoryLocation:(NSInteger)location {

// When the user starts swiping the cell this method is called
- (void)swipeTableViewCellDidStartSwiping:(MCSwipeTableViewCell *)cell {
// NSLog(@"Did start swiping the cell!");
// NSLog(@"Did start swiping the cell!");
NSIndexPath *indexPath = [self.storyTitlesTable indexPathForCell:cell];

self.swipingIndexPath = indexPath;
}

// When the user is dragging, this method is called and return the dragged percentage from the border
Expand All @@ -2248,23 +2252,22 @@ - (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell didSwipWithPercentage:(C
- (void)swipeTableViewCell:(MCSwipeTableViewCell *)cell
didEndSwipingSwipingWithState:(MCSwipeTableViewCellState)state
mode:(MCSwipeTableViewCellMode)mode {
NSIndexPath *indexPath = [self.storyTitlesTable indexPathForCell:cell];
if (!indexPath) {
// This can happen if the user swipes on a cell that is being refreshed.
return;
NSIndexPath *endedOnIndexPath = [self.storyTitlesTable indexPathForCell:cell];
NSInteger storyIndex = [storiesCollection indexFromLocation:self.swipingIndexPath.row];
NSDictionary *story = [[storiesCollection activeFeedStories] objectAtIndex:storyIndex];

if (endedOnIndexPath != self.swipingIndexPath) {
NSLog(@"Swipe started at row %@ but ended at %@ for %@", self.swipingIndexPath, endedOnIndexPath, story[@"story_title"]); // log
}

NSInteger storyIndex = [storiesCollection indexFromLocation:indexPath.row];
NSDictionary *story = [[storiesCollection activeFeedStories] objectAtIndex:storyIndex];

if (state == MCSwipeTableViewCellState1) {
// Saved
[storiesCollection toggleStorySaved:story];
[self reloadIndexPath:indexPath withRowAnimation:UITableViewRowAnimationFade];
[self reloadIndexPath:self.swipingIndexPath withRowAnimation:UITableViewRowAnimationFade];
} else if (state == MCSwipeTableViewCellState3) {
// Read
[storiesCollection toggleStoryUnread:story];
[self reloadIndexPath:indexPath withRowAnimation:UITableViewRowAnimationFade];
[self reloadIndexPath:self.swipingIndexPath withRowAnimation:UITableViewRowAnimationFade];
}
}

Expand Down
Loading

0 comments on commit abeb3d4

Please sign in to comment.