Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soundcloud #351

Merged
merged 25 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
29ef86f
Add email to feedback page
oskarrough Jun 9, 2019
45db5d2
add-current-track button
Jun 20, 2019
01ae90b
Bump handlebars from 4.0.11 to 4.1.2
dependabot[bot] Jun 20, 2019
7191eec
Merge pull request #346 from internet4000/feat/add-current-track
hugurp Jun 20, 2019
fa624c9
Switch to redirect login for iOS
oskarrough Jun 22, 2019
8464745
Lint
oskarrough Jun 23, 2019
ae8100e
Fix sendAction deprecation
oskarrough Jun 23, 2019
5e58731
Merge pull request #348 from internet4000/bug/ios-auth
oskarrough Jun 23, 2019
65bd933
Merge pull request #347 from internet4000/dependabot/npm_and_yarn/han…
hugurp Jul 15, 2019
83461d5
improve offline dummy and transition opacity
Jul 16, 2019
b618cfe
Merge pull request #349 from internet4000/feat/offline-dummy
oskarrough Jul 17, 2019
fc4cfc7
validator update for soundcloud
Jun 28, 2019
e59f5dd
try with local player
Jun 29, 2019
4a1e518
bump version of r4 player
Jul 16, 2019
3b98860
update latest r4 player
Jul 16, 2019
43ef88a
working yarn.lock from master
Jul 16, 2019
db4f9a8
working yarn.lock from master
Jul 16, 2019
95b1df4
validate youtube/soundcloud
Jul 16, 2019
73c4a4d
fetch soundcloud track title from inserting widget (and removing it)
Jul 17, 2019
d1e48d1
update to the latest npm:radio4000-player version
Jul 17, 2019
d54b289
lint
Jul 17, 2019
c6916c2
remove annoying title on the whole player!!!
Jul 17, 2019
cdbb6fa
update latest r4-player version
Jul 18, 2019
f70ccb2
Fix half-pixel rendering for burger menu on Windows
oskarrough Jul 18, 2019
a1cba4b
Merge pull request #350 from internet4000/feat/soundcloud
hugurp Jul 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ module.exports = {
// Change errors to warnings to avoid the CI builds failing.
rules: {
'capitalized-comments': 'off',
indent: 'warn',
'ember/closure-actions': 'warn',
'ember/new-module-imports': 'off',
'ember/no-on-calls-in-components': 'warn',
'ember/use-brace-expansion': 'warn',
'no-alert': 'off',
'object-curly-spacing': 'off',
semi: 'off',
'space-before-function-paren': 'off',
// Disable a few "best practices" for now
'ember/closure-actions': 'warn',
'ember/new-module-imports': 'off',
'ember/no-on-calls-in-components': 'warn',
'ember/use-brace-expansion': 'warn'
curly: ['error', 'multi-line'],
indent: 'warn',
semi: 'off'
},
overrides: [
// node files
Expand Down
11 changes: 11 additions & 0 deletions app/auth/login/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Controller from '@ember/controller'

export default Controller.extend({
actions: {
// This does nothing else but route the action
// up to a "login" action on the parent `auth` route.
submitLogin(...args) {
this.send('login', args)
}
}
})
14 changes: 8 additions & 6 deletions app/auth/login/route.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import Ember from 'ember';

const {Route, get} = Ember;
import Route from '@ember/routing/route'
import {get} from '@ember/object'

export default Route.extend({
beforeModel(transition) {
if (get(this, 'session.isAuthenticated')) {
return transition.send('redirectAfterAuth');
return transition.send('redirectAfterAuth')
}
},
actions: {
login() {
return true
},
redirectAfterAuth() {
return true;
return true
}
}
});
})
2 changes: 1 addition & 1 deletion app/auth/login/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</h1>
</header>
<div class="Container Container--small">
{{user-login onLogin="login"}}
{{user-login onLogin=(action "submitLogin")}}
</div>
</section>
</div>
17 changes: 12 additions & 5 deletions app/auth/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {Route, get, inject, debug} = Ember;

export default Route.extend(resetScroll, {
flashMessages: inject.service(),

onLoginError(err) {
const messages = get(this, 'flashMessages');
let msg;
Expand All @@ -31,16 +32,22 @@ export default Route.extend(resetScroll, {
messages.warning(msg, {timeout: 10000});
}
},

actions: {
login(provider, email, password) {
const flashMessages = get(this, 'flashMessages');
let data = {
login([provider, email, password]) {
const flashMessages = get(this, 'flashMessages')

let options = {
provider,
email,
password
};
}

// iOS has issues with the default 'popup' method, so we switch to redirect.
const iOS = Boolean(navigator.platform) && /iPhone|iPod/.test(navigator.platform)
if (iOS) options.redirect = true

get(this, 'session').open('firebase', data).then(() => {
get(this, 'session').open('firebase', options).then(() => {
flashMessages.info('You are now signed in!');
this.send('redirectAfterAuth');
}).catch(error => {
Expand Down
32 changes: 10 additions & 22 deletions app/components/track-form-add/template.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
{{#if player.isPlaying}}
<div class="u-dn">
{{#btn-group class="BtnGroup--right"}}
{{#if session.currentUser.channels.firstObject.isPremium}}
<button
{{action "prefillCurrentTrack"}}
class="Btn"
type="button"
title="Add the current 'on air' track into your radio [⌨ a]">
Copy current track
</button>
{{else}}
<button
{{action "inviteToPremium"}}
class="Btn Muted"
type="button"
title="(Upgrade) Add the current 'on air' track into your radio [⌨ a]">
Copy current track
</button>
{{/if}}
{{/btn-group}}
</div>
{{#btn-group class="BtnGroup--right"}}
<button
{{action "prefillCurrentTrack"}}
class="Btn"
type="button"
title="Add the current 'on air' track into your radio">
Copy current track
</button>
{{/btn-group}}
{{/if}}

{{#form-group
Expand All @@ -32,7 +20,7 @@
type="url"
value=value
required="required"
placeholder="Paste in a YouTube link"
placeholder="Link to a Youtube or Soundcloud media"
autoFocus=true}}
{{/form-group}}

Expand Down
62 changes: 58 additions & 4 deletions app/components/track-form/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Ember from 'ember';
import youtubeUrlToId from 'radio4000/utils/youtube-url-to-id';
import {fetchTitle} from 'radio4000/utils/youtube-api';
import {fetchDiscogsInfo} from 'radio4000/utils/discogs-api';
import {task, timeout} from 'ember-concurrency';
Expand Down Expand Up @@ -42,10 +41,22 @@ export default Component.extend({
}

// Because the URL might have changed
const newid = youtubeUrlToId(track.get('url'))
let parsedMediaUrl;

try {
parsedMediaUrl = mediaUrlParser(track.get('url'))
} catch (e) {
return;
}

const newid = parsedMediaUrl.id
if (newid) {
track.set('ytid', newid);
get(this, 'fetchTitle').perform()
if (parsedMediaUrl.provider === 'youtube') {
get(this, 'fetchYoutubeTitle').perform()
} else if (parsedMediaUrl.provider === 'soundcloud') {
get(this, 'fetchSoundcloudTitle').perform()
}
}
}),

Expand All @@ -64,14 +75,57 @@ export default Component.extend({
return `https://www.discogs.com/search/?q=${title}&type=all`
}),

fetchTitle: task(function * () {
fetchYoutubeTitle: task(function * () {
yield timeout(250); // throttle
const track = get(this, 'track')
const ytid = track.get('ytid')
let title = yield fetchTitle(ytid)
track.set('title', title)
}).restartable(),

fetchSoundcloudTitle: task(function * () {
yield timeout(250); // throttle
const track = get(this, 'track')
const trackUrl = track.get('url')

// insert temporarily the soundcloud API script
// for the widget to work
// maybe the soundcloud widget code does already exist
let SC = window.SC
if (!window.SC) {
let soundcloudApiScript = document.createElement('script')
soundcloudApiScript.setAttribute('src', 'https://w.soundcloud.com/player/api.js')
soundcloudApiScript.setAttribute('id', 'SoundcloudApiScript')
this.get('element').appendChild(soundcloudApiScript)
// assign the newly created soundcloud API code to our variable
SC = window.SC
}

// create and insert a soundcloud widget,
// so we can fetch the title from the track
let soundcloudIframe = document.createElement('iframe');
soundcloudIframe.setAttribute('id', 'SoundcloudIframe')
soundcloudIframe.setAttribute('src', `https://w.soundcloud.com/player/?url=${trackUrl}`)
soundcloudIframe.classList.add('u-dn');
this.get('element').appendChild(soundcloudIframe)

// eslint-disable-next-line new-cap
var widget = SC.Widget(soundcloudIframe)
const readyEvent = SC.Widget.Events.READY

// attach the ready event to query the track
widget.bind(readyEvent, () => {
widget.getCurrentSound(sound => {
track.set('title', sound.title)

// cleanup all this mess like nothing happened
widget.unbind(readyEvent)
// this.get('element').removeChild(document.querySelector('#SoundcloudApiScript'))
this.get('element').removeChild(document.querySelector('#SoundcloudIframe'))
})
})
}).restartable(),

fetchDiscogsInfo: task(function * () {
const mediaUrl = mediaUrlParser(this.get('track.discogsUrl'))
// Make sure we are dealing with a Discogs URL
Expand Down
2 changes: 1 addition & 1 deletion app/components/user-login/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default Component.extend({

actions: {
login(provider, email, password) {
this.sendAction('onLogin', provider, email, password);
this.onLogin(provider, email, password)
},

resetPassword(email) {
Expand Down
3 changes: 1 addition & 2 deletions app/components/x-playback/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
autoplay="true"
r4-url="true"
track-id={{track.id}}
title="Radio4000 player. [⌨ g c = current channel] [⌨ g x = curent track]"
></radio4000-player>
{{!-- <script src="http://localhost:4002/radio4000-player.min.js"></script> --}}
<!-- <script src="http://localhost:4002/radio4000-player.min.js"></script> -->
</div>

<div class="Playback-layoutButtons">
Expand Down
2 changes: 1 addition & 1 deletion app/feedback/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1>Feedback</h1>
</header>
<div class="Container">
<p>Comments, problem reports, feature ideas or any thoughts are always welcome.</p>
<p>Comments, problem reports, feature ideas or any thoughts are always welcome. Prefer email? <a href="mailto:contact@radio4000.com">contact@radio4000.com</a>.</p>

{{feedback-form-google-spreadsheet
scriptUrl="https://script.google.com/macros/s/AKfycbyuhfTf74Lcc5pvfXfxdgMfE4wpDiw8DJN1dzhN2YLRpAa2kBI/exec"}}
Expand Down
31 changes: 22 additions & 9 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,28 @@
<!-- a dummy app that appears independently from Ember and is removed by ember asap -->
<style>
.DummyApp {
z-index: 2;
/* above the main r4 nav menu */
z-index: 7;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: hsl(60, 4%, 91%);
}
.DummyApp--hidden {
display: none;
.DummyApp--hidden .DummyApp-inner {
opacity: 0;
}

.DummyApp-inner {
transition: opacity 700ms ease-in;
opacity: 1;
}

.DummyApp--hidden .DummyApp-loading {
transform: translateY(50%);
}

.DummyApp-inner {
position: absolute;
top: 50%;
Expand All @@ -55,6 +66,8 @@
}
.DummyApp-loading {
margin-bottom: 1rem;
transition: transform 500ms ease-in;
transform: translateY(0%);
}
.DummyApp p {
color: hsl(0, 0%, 30%); /*$dark*/
Expand Down Expand Up @@ -103,8 +116,8 @@
console.log('A human feel.')

// Show dummy app
var dummyApp = document.querySelectorAll('.DummyApp')
dummyApp[0].classList.remove('DummyApp--hidden')
var dummyApp = document.querySelector('.DummyApp')
dummyApp.classList.remove('DummyApp--hidden')

// Insert a random sentence to make waiting fun/less annoying
var sentences = [
Expand Down Expand Up @@ -139,13 +152,13 @@
'Omunye mzuzu, sicela'
]
var randomSentence = sentences[Math.floor(Math.random() * sentences.length)]
var slogan = document.querySelectorAll('.DummyApp-slogan')
slogan[0].innerHTML = randomSentence + '…'
var slogan = document.querySelector('.DummyApp-slogan')
slogan.innerHTML = randomSentence + '…'

// Internet connection check
var dummyBody = document.querySelectorAll('.DummyApp-body')
var dummyBody = document.querySelector('.DummyApp-inner')
if (!navigator.onLine) {
dummyBody[0].innerHTML =
dummyBody.innerHTML =
'<p><strong>It seems that you are not connected to the internet -_-</strong></p><p>Find the internet and then reload this page.</p><p><button class="Btn" onclick="window.location.reload()">Reload</button></p>'
}
})()
Expand Down
4 changes: 2 additions & 2 deletions app/models/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const Validations = buildValidations({
url: [
validator('presence', {
presence: true,
message: 'A YouTube URL (https://...) is required to add a new track'
message: 'A YouTube or Soundcloud media URL (https://...) are required to add a new track'
}),
validator('youtube-url')
validator('provider-url')
],
discogsUrl: [
validator('discogs-url')
Expand Down
7 changes: 4 additions & 3 deletions app/styles/components/_aside.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
top: 1rem;
left: 1rem;
z-index: 7;

display: block;
width: 2.7rem;
height: 2.7rem;

// "burger" lines inside
display: block;
span {
display: block;
height: 0.2rem;
margin: 0.2rem;
height: 3px;
margin: 3px;
background-color: black;
border-radius: $border-radius;
}
Expand Down
Loading