Skip to content

Commit

Permalink
minor changes, add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saadsaifse committed Sep 18, 2023
1 parent cfbe4cb commit 7645914
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 176 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Strava for Obsidian plugin

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css
18 changes: 6 additions & 12 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {
addIcon,
} from 'obsidian'
import { AuthenticationConfig } from 'strava-v3'
import {
fetchAthleteActivities,
fetchAthleteActivity,
fetchDetailedActivities,
} from 'src/retriever'
import { fetchAthleteActivities, fetchAthleteActivity } from 'src/retriever'
import FileManager from 'src/fileManager'
import { ee } from 'src/eventEmitter'
import { DateTime } from 'luxon'
Expand All @@ -32,15 +28,13 @@ interface StravaActivitiesSettings {
const DEFAULT_SETTINGS: StravaActivitiesSettings = {
authSettings: {
access_token: '',
client_id: '113274', // TODO: reset after input handler is implemented
client_secret: 'a596836c309eb7f08067aa7504907664998c896f', // TODO: reset after input handler is implemented
client_id: '',
client_secret: '',
redirect_uri: 'obsidian://obsidianforstrava/callback',
},
syncSettings: {
// lastSyncedAt: '2023-09-14T14:44:56.106Z', // setting to avoid excessive retrievals during dev
// activityDetailsRetrievedUntil: '2023-01-01T14:44:56.106Z', // setting to avoid excessive retrievals during dev
lastSyncedAt: '', // setting to avoid excessive retrievals during dev
activityDetailsRetrievedUntil: '', // setting to avoid excessive retrievals during dev
lastSyncedAt: '', // e.g., '2023-09-14T14:44:56.106Z'
activityDetailsRetrievedUntil: '', // e.g., '2023-01-01T14:44:56.106Z'
},
}

Expand Down Expand Up @@ -126,7 +120,7 @@ export default class StravaActivities extends Plugin {
)
const activityId =
path.basename(activityDateFolder)
const activity = await fetchAthleteActivity(
await fetchAthleteActivity(
Number(activityId),
true,
file.path
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "strava-obsidian",
"name": "Strava Activities",
"name": "Strava for Obsidian",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "Store your Strava activities in your Obsidian vault.",
"description": "Store and visualize Strava activities in your Obsidian vault.",
"author": "Saad Saif",
"authorUrl": "https://github.com/saadsaifse/strava-obsidian",
"fundingUrl": "https://www.buymeacoffee.com/saadsaif",
Expand Down
141 changes: 2 additions & 139 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{
"name": "obsidian-sample-plugin",
"name": "strava-for-obsidian",
"version": "1.0.0",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"description": "Store and visualize Strava activities in your Obsidian vault. (https://github.com/saadsaifse/strava-obsidian)",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
"keywords": ["obsidian", "strava", "plugin"],
"author": "Saad Saif (https://github.com/saadsaifse)",
"license": "MIT",
"devDependencies": {
"@types/lodash": "^4.14.198",
"@types/luxon": "^3.3.2",
"@types/node": "^16.11.6",
"@types/passport": "^1.0.12",
"@types/request": "^2.48.8",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
Expand Down
19 changes: 13 additions & 6 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,19 @@ class Auth {
}

async authenticate(authConfig: AuthenticationConfig) {
this.authConfig = authConfig
stravaApi.config(authConfig)
const url = await stravaApi.oauth.getRequestAccessURL({
scope: 'activity:read_all',
})
await open(url, undefined)
try {
this.authConfig = authConfig
stravaApi.config(authConfig)
const url = await stravaApi.oauth.getRequestAccessURL({
scope: 'activity:read_all',
})
await open(url, undefined)
} catch (error) {
console.log('Error while authenticating', error)
new Notice(
'Error authenticating. Please make sure to set Client ID and Client Secret in plugin settings first.'
)
}
}

async OAuthCallback(args: ObsidianProtocolData) {
Expand Down
2 changes: 1 addition & 1 deletion src/mapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ maxZoom: 18
zoomDelta: 0.5
geojsonFolder: .
`
const leafletBlock = `~~~leaflet \n${leafletConfig} \n~~~`
const leafletBlock = `~~~leaflet \n${leafletConfig} ~~~`
return leafletBlock
}

Expand Down
2 changes: 1 addition & 1 deletion src/retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function fetchAthleteActivities(
if (!auth.validateUtilization(stravaApi.rateLimiting)) {
return []
}
var args = {
const args = {
page: page,
per_page: pageSize,
after:
Expand Down
9 changes: 0 additions & 9 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
/*
This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.
If your plugin does not need CSS, delete this file.
*/

.svg-icon.stravaIcon {
fill: currentColor;
}

0 comments on commit 7645914

Please sign in to comment.