Skip to content

Commit

Permalink
Clicking c opens comments page on HN. (#4)
Browse files Browse the repository at this point in the history
* Clicking `c` opens comments page on HN.

* Refine workflows, Add CD workflow
  • Loading branch information
yayoc committed Nov 9, 2019
1 parent a503950 commit 022bdcc
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 27 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Continuous Deployment

on:
push:
tags:
- "v*.*.*"

jobs:
publish:
name: Publishing for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
rust: [nightly]
include:
- os: macos-latest
artifact_prefix: macos
target: x86_64-apple-darwin
- os: ubuntu-latest
artifact_prefix: linux
target: x86_64-unknown-linux-gnu

steps:
- name: Installing Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: Installing needed macOS dependencies
if: matrix.os == 'macos-latest'
run: brew install openssl@1.1
- name: Installing needed Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y -qq pkg-config libssl-dev
- name: Checking out sources
uses: actions/checkout@v1
- name: Running cargo build
uses: actions-rs/cargo@v1
with:
command: build
toolchain: ${{ matrix.rust }}
args: --release --target ${{ matrix.target }}

- name: Packaging final binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
strip spt
tar czvf spotify-tui-${{ matrix.artifact_prefix }}.tar.gz spt
shasum -a 256 spotify-tui-${{ matrix.artifact_prefix }}.tar.gz > spotify-tui-${{ matrix.artifact_prefix }}.sha256
- name: Releasing assets
uses: softprops/action-gh-release@v1
with:
files: |
target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.tar.gz
target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.
25 changes: 0 additions & 25 deletions .github/workflows/cross_compile.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
|CTRL+d|Scroll window downwards|
|g|Jump to top|
|G|Jump to bottom|
|Enter|Open default browser|
|Enter|Open the article with default browser|
|c|Open comments with default browser|
|CTRL+r|Reload articles|
|CTRL+c|Quit|

6 changes: 6 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ impl App {
}
}

pub fn open_comments(&self) {
let s = &self.stories[self.cur_index];
let url = format!("https://news.ycombinator.com/item?id={}", s.id);
webbrowser::open(url.as_str()).expect("Can't open your browser.");
}

pub fn cursor_up(&mut self) {
if self.cur_index > 0 {
self.cur_index -= 1;
Expand Down
2 changes: 1 addition & 1 deletion src/hn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mockito;

#[derive(Deserialize, Debug)]
pub struct Story {
id: i64,
pub id: i64,
by: String,
descendants: i64,
kids: Option<Vec<i64>>,
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ fn main() {
Event::Key(Key::Char('\n')) => {
a.open_browser();
}
Event::Key(Key::Char('c')) => {
a.open_comments();
}
Event::Key(Key::Ctrl('d')) => {
a.cursor_jump_down();
}
Expand Down

0 comments on commit 022bdcc

Please sign in to comment.