Skip to content

Commit 022bdcc

Browse files
authored
Clicking c opens comments page on HN. (#4)
* Clicking `c` opens comments page on HN. * Refine workflows, Add CD workflow
1 parent a503950 commit 022bdcc

File tree

7 files changed

+73
-27
lines changed

7 files changed

+73
-27
lines changed

.github/workflows/cd.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Continuous Deployment
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
publish:
10+
name: Publishing for ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [macos-latest, ubuntu-latest]
15+
rust: [nightly]
16+
include:
17+
- os: macos-latest
18+
artifact_prefix: macos
19+
target: x86_64-apple-darwin
20+
- os: ubuntu-latest
21+
artifact_prefix: linux
22+
target: x86_64-unknown-linux-gnu
23+
24+
steps:
25+
- name: Installing Rust toolchain
26+
uses: actions-rs/toolchain@v1
27+
with:
28+
toolchain: ${{ matrix.rust }}
29+
override: true
30+
- name: Installing needed macOS dependencies
31+
if: matrix.os == 'macos-latest'
32+
run: brew install [email protected]
33+
- name: Installing needed Ubuntu dependencies
34+
if: matrix.os == 'ubuntu-latest'
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install -y -qq pkg-config libssl-dev
38+
- name: Checking out sources
39+
uses: actions/checkout@v1
40+
- name: Running cargo build
41+
uses: actions-rs/cargo@v1
42+
with:
43+
command: build
44+
toolchain: ${{ matrix.rust }}
45+
args: --release --target ${{ matrix.target }}
46+
47+
- name: Packaging final binary
48+
shell: bash
49+
run: |
50+
cd target/${{ matrix.target }}/release
51+
strip spt
52+
tar czvf spotify-tui-${{ matrix.artifact_prefix }}.tar.gz spt
53+
shasum -a 256 spotify-tui-${{ matrix.artifact_prefix }}.tar.gz > spotify-tui-${{ matrix.artifact_prefix }}.sha256
54+
- name: Releasing assets
55+
uses: softprops/action-gh-release@v1
56+
with:
57+
files: |
58+
target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.tar.gz
59+
target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.sha256
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.

.github/workflows/cross_compile.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
|CTRL+d|Scroll window downwards|
1616
|g|Jump to top|
1717
|G|Jump to bottom|
18-
|Enter|Open default browser|
18+
|Enter|Open the article with default browser|
19+
|c|Open comments with default browser|
1920
|CTRL+r|Reload articles|
2021
|CTRL+c|Quit|
2122

src/app.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ impl App {
4141
}
4242
}
4343

44+
pub fn open_comments(&self) {
45+
let s = &self.stories[self.cur_index];
46+
let url = format!("https://news.ycombinator.com/item?id={}", s.id);
47+
webbrowser::open(url.as_str()).expect("Can't open your browser.");
48+
}
49+
4450
pub fn cursor_up(&mut self) {
4551
if self.cur_index > 0 {
4652
self.cur_index -= 1;

src/hn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use mockito;
1717

1818
#[derive(Deserialize, Debug)]
1919
pub struct Story {
20-
id: i64,
20+
pub id: i64,
2121
by: String,
2222
descendants: i64,
2323
kids: Option<Vec<i64>>,

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ fn main() {
9090
Event::Key(Key::Char('\n')) => {
9191
a.open_browser();
9292
}
93+
Event::Key(Key::Char('c')) => {
94+
a.open_comments();
95+
}
9396
Event::Key(Key::Ctrl('d')) => {
9497
a.cursor_jump_down();
9598
}

0 commit comments

Comments
 (0)