2828
2929mod icon;
3030mod player;
31+ /// The demo's library. Compiled only into the demo, so the client that
32+ /// talks to a real server carries none of it.
33+ #[ cfg( feature = "demo" ) ]
34+ mod seed;
3135mod vim;
3236
3337use std:: time:: Duration ;
@@ -767,289 +771,6 @@ impl App {
767771 }
768772 }
769773
770- /// Put something in an empty demo library, so the page has a list on it.
771- ///
772- /// Through `mutate`, not through SQL: the demo runs the same `apply` as
773- /// every other peer, and seeding it any other way would be showing
774- /// something the engine did not do.
775- #[ cfg( feature = "demo" ) ]
776- fn seed ( peer : & mut Peer ) {
777- if !peer. items . is_empty ( ) {
778- return ;
779- }
780- // Public-domain recordings on Wikimedia Commons, by way of the mp3
781- // Commons transcodes every audio file gets: a browser plays mp3
782- // everywhere, and Vorbis in an `.ogg` does not play in Safari at all.
783- //
784- // The URL goes in `file`, which is what that column has always been
785- // for — "the bytes travel over HTTP and only the name of them is
786- // synced". Nothing about the log changes to carry a recording.
787- //
788- // Every one of these was checked: public domain by Commons' own
789- // licence field, and a transcode that answers with `audio/mpeg` and a
790- // range request. A dead link here is a silent demo, so they are not
791- // taken on trust.
792- const LIBRARY : & [ ( & str , & str , & str , i64 , & str ) ] = & [
793- (
794- "Air on the G String" ,
795- "Johann Sebastian Bach" ,
796- "Orchestral Suite No. 3" ,
797- 260000 ,
798- "https://upload.wikimedia.org/wikipedia/commons/transcoded/1/1e/Air_%28Bach%29.ogg/Air_%28Bach%29.ogg.mp3" ,
799- ) ,
800- (
801- "Toccata and Fugue in D minor, BWV 565" ,
802- "Johann Sebastian Bach" ,
803- "Organ Works" ,
804- 514000 ,
805- "https://upload.wikimedia.org/wikipedia/commons/transcoded/b/be/Toccata_et_Fugue_BWV565.ogg/Toccata_et_Fugue_BWV565.ogg.mp3" ,
806- ) ,
807- (
808- "Für Elise" ,
809- "Ludwig van Beethoven" ,
810- "Bagatelles" ,
811- 177000 ,
812- "https://upload.wikimedia.org/wikipedia/commons/transcoded/7/7b/FurElise.ogg/FurElise.ogg.mp3" ,
813- ) ,
814- (
815- "Moonlight Sonata - I. Adagio sostenuto" ,
816- "Ludwig van Beethoven" ,
817- "Piano Sonata No. 14" ,
818- 307000 ,
819- "https://upload.wikimedia.org/wikipedia/commons/transcoded/d/d0/Moonlight_Sonata.ogg/Moonlight_Sonata.ogg.mp3" ,
820- ) ,
821- (
822- "Symphony No. 5 - I. Allegro con brio" ,
823- "Ludwig van Beethoven" ,
824- "Symphony No. 5" ,
825- 436000 ,
826- "https://upload.wikimedia.org/wikipedia/commons/transcoded/5/5b/Ludwig_van_Beethoven_-_Symphonie_5_c-moll_-_1._Allegro_con_brio.ogg/Ludwig_van_Beethoven_-_Symphonie_5_c-moll_-_1._Allegro_con_brio.ogg.mp3" ,
827- ) ,
828- (
829- "Symphony No. 5 - III. Allegro" ,
830- "Ludwig van Beethoven" ,
831- "Symphony No. 5" ,
832- 336000 ,
833- "https://upload.wikimedia.org/wikipedia/commons/transcoded/5/5b/Ludwig_van_Beethoven_-_symphony_no._5_in_c_minor%2C_op._67_-_iii._allegro.ogg/Ludwig_van_Beethoven_-_symphony_no._5_in_c_minor%2C_op._67_-_iii._allegro.ogg.mp3" ,
834- ) ,
835- (
836- "Eine kleine Nachtmusik - I. Allegro" ,
837- "Wolfgang Amadeus Mozart" ,
838- "Eine kleine Nachtmusik" ,
839- 253000 ,
840- "https://upload.wikimedia.org/wikipedia/commons/transcoded/6/68/Mozart_K525_Serenade_in_G_Major_1_-_Allegro.ogg/Mozart_K525_Serenade_in_G_Major_1_-_Allegro.ogg.mp3" ,
841- ) ,
842- (
843- "Eine kleine Nachtmusik - III. Minuet" ,
844- "Wolfgang Amadeus Mozart" ,
845- "Eine kleine Nachtmusik" ,
846- 123000 ,
847- "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/a0/Mozart_K525_Serenade_in_G_Major_3_-_Minuet.ogg/Mozart_K525_Serenade_in_G_Major_3_-_Minuet.ogg.mp3" ,
848- ) ,
849- (
850- "Eine kleine Nachtmusik - IV. Rondo" ,
851- "Wolfgang Amadeus Mozart" ,
852- "Eine kleine Nachtmusik" ,
853- 194000 ,
854- "https://upload.wikimedia.org/wikipedia/commons/transcoded/3/3b/Mozart_K525_Serenade_in_G_Major_4_-_Rondo.ogg/Mozart_K525_Serenade_in_G_Major_4_-_Rondo.ogg.mp3" ,
855- ) ,
856- (
857- "Ballade No. 1 in G minor, Op. 23" ,
858- "Frédéric Chopin" ,
859- "Ballades" ,
860- 679000 ,
861- "https://upload.wikimedia.org/wikipedia/commons/transcoded/3/33/Frederic_Chopin_-_ballade_no._1_in_g_minor%2C_op._23.ogg/Frederic_Chopin_-_ballade_no._1_in_g_minor%2C_op._23.ogg.mp3" ,
862- ) ,
863- (
864- "Ballade No. 2 in F major, Op. 38" ,
865- "Frédéric Chopin" ,
866- "Ballades" ,
867- 420000 ,
868- "https://upload.wikimedia.org/wikipedia/commons/transcoded/c/cf/Frederic_Chopin_-_ballade_no._2_in_f_major%2C_op._38.ogg/Frederic_Chopin_-_ballade_no._2_in_f_major%2C_op._38.ogg.mp3" ,
869- ) ,
870- (
871- "Swan Lake - Dance of the Swans" ,
872- "Pyotr Ilyich Tchaikovsky" ,
873- "Swan Lake" ,
874- 81000 ,
875- "https://upload.wikimedia.org/wikipedia/commons/transcoded/3/35/Tchaikovsky_Swan_Lake_Op.20_No.13._Danses_des_cygnes_IV.ogg/Tchaikovsky_Swan_Lake_Op.20_No.13._Danses_des_cygnes_IV.ogg.mp3" ,
876- ) ,
877- (
878- "Swan Lake - Scene" ,
879- "Pyotr Ilyich Tchaikovsky" ,
880- "Swan Lake" ,
881- 150000 ,
882- "https://upload.wikimedia.org/wikipedia/commons/transcoded/1/1f/Tchaikovsky_Swan_Lake_Op.20_No.10._Sc%C3%A8ne.ogg/Tchaikovsky_Swan_Lake_Op.20_No.10._Sc%C3%A8ne.ogg.mp3" ,
883- ) ,
884- (
885- "Winter - I. Allegro non molto" ,
886- "Antonio Vivaldi" ,
887- "The Four Seasons" ,
888- 198000 ,
889- "https://upload.wikimedia.org/wikipedia/commons/transcoded/0/04/Vivaldi_Winter_mvt_1_Allegro_non_molto_-_The_USAF_Concert.ogg/Vivaldi_Winter_mvt_1_Allegro_non_molto_-_The_USAF_Concert.ogg.mp3" ,
890- ) ,
891- (
892- "Water Music - Allegro" ,
893- "George Frideric Handel" ,
894- "Water Music" ,
895- 125000 ,
896- "https://upload.wikimedia.org/wikipedia/commons/transcoded/d/de/Handel%27s_Water_Music_-_11._Allegro_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_11._Allegro_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
897- ) ,
898- (
899- "Water Music - Alla hornpipe" ,
900- "George Frideric Handel" ,
901- "Water Music" ,
902- 229000 ,
903- "https://upload.wikimedia.org/wikipedia/commons/transcoded/5/5c/Handel%27s_Water_Music_-_12._Alla_hornpipe_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_12._Alla_hornpipe_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
904- ) ,
905- (
906- "Water Music - Minuet" ,
907- "George Frideric Handel" ,
908- "Water Music" ,
909- 195000 ,
910- "https://upload.wikimedia.org/wikipedia/commons/transcoded/c/c9/Handel%27s_Water_Music_-_13._Minuet_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_13._Minuet_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
911- ) ,
912- (
913- "Water Music - Lentement" ,
914- "George Frideric Handel" ,
915- "Water Music" ,
916- 136000 ,
917- "https://upload.wikimedia.org/wikipedia/commons/transcoded/7/75/Handel%27s_Water_Music_-_14._Lentement_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_14._Lentement_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
918- ) ,
919- (
920- "Water Music - Bourrée" ,
921- "George Frideric Handel" ,
922- "Water Music" ,
923- 76000 ,
924- "https://upload.wikimedia.org/wikipedia/commons/transcoded/2/2d/Handel%27s_Water_Music_-_15._Bourree_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_15._Bourree_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
925- ) ,
926- (
927- "Water Music - Sarabande" ,
928- "George Frideric Handel" ,
929- "Water Music" ,
930- 168000 ,
931- "https://upload.wikimedia.org/wikipedia/commons/transcoded/e/e8/Handel%27s_Water_Music_-_16._Sarabande_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_16._Sarabande_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
932- ) ,
933- (
934- "Water Music - Rigaudon" ,
935- "George Frideric Handel" ,
936- "Water Music" ,
937- 156000 ,
938- "https://upload.wikimedia.org/wikipedia/commons/transcoded/c/c7/Handel%27s_Water_Music_-_17._%26_18._Rigaudon_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_17._%26_18._Rigaudon_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
939- ) ,
940- (
941- "Water Music - Menuet" ,
942- "George Frideric Handel" ,
943- "Water Music" ,
944- 227000 ,
945- "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/ac/Handel%27s_Water_Music_-_19._%26_20._Menuet_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_19._%26_20._Menuet_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
946- ) ,
947- (
948- "Water Music - Gigue" ,
949- "George Frideric Handel" ,
950- "Water Music" ,
951- 85000 ,
952- "https://upload.wikimedia.org/wikipedia/commons/transcoded/f/fe/Handel%27s_Water_Music_-_21._%26_22._Gigue_-_Chamber_Orchestra_-_United_States_Marine_Band.opus/Handel%27s_Water_Music_-_21._%26_22._Gigue_-_Chamber_Orchestra_-_United_States_Marine_Band.opus.mp3" ,
953- ) ,
954- (
955- "Impromptu in G-flat major, D. 899" ,
956- "Franz Schubert" ,
957- "Impromptus" ,
958- 301000 ,
959- "https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0b/Schubert_Gb_Impromptu_Andriy_Bondarenko_%28Live%29.ogg/Schubert_Gb_Impromptu_Andriy_Bondarenko_%28Live%29.ogg.mp3" ,
960- ) ,
961- (
962- "Hungarian Dance No. 5" ,
963- "Johannes Brahms" ,
964- "Hungarian Dances" ,
965- 175000 ,
966- "https://upload.wikimedia.org/wikipedia/commons/transcoded/0/0a/Brahms_nikisch_hd5.ogg/Brahms_nikisch_hd5.ogg.mp3" ,
967- ) ,
968- (
969- "Clair de lune" ,
970- "Claude Debussy" ,
971- "Suite bergamasque" ,
972- 304000 ,
973- "https://upload.wikimedia.org/wikipedia/commons/transcoded/b/be/Clair_de_lune_%28Claude_Debussy%29_Suite_bergamasque.ogg/Clair_de_lune_%28Claude_Debussy%29_Suite_bergamasque.ogg.mp3" ,
974- ) ,
975- ] ;
976- for ( title, artist, album, ms, file) in LIBRARY {
977- let _ = peer. client . mutate ( mutators:: add_song (
978- ( * title) . into ( ) ,
979- ( * artist) . into ( ) ,
980- ( * album) . into ( ) ,
981- * ms,
982- ( * file) . into ( ) ,
983- ) ) ;
984- }
985- peer. refresh ( ) ;
986- // A few of them hearted, so the playlist is not empty either.
987- let hearted: Vec < harken:: Id < harken:: tables:: Media > > = peer
988- . items
989- . iter ( )
990- . filter ( |i| {
991- matches ! (
992- i. title. as_str( ) ,
993- "Clair de lune" | "Für Elise" | "Air on the G String"
994- )
995- } )
996- . map ( |i| i. id )
997- . collect ( ) ;
998- for id in hearted {
999- let _ = peer
1000- . client
1001- . mutate ( mutators:: add_to_playlist ( peer. playlist , id) ) ;
1002- }
1003- peer. refresh ( ) ;
1004-
1005- // Two more playlists, so the sidebar shows what a playlist *is* here:
1006- // an ordered list somebody made, of which "Favourites" is one and not
1007- // a special case. Made after the hearts above so that the first
1008- // playlist — the one a heart means — stays Favourites.
1009- const SETS : & [ ( & str , & [ & str ] ) ] = & [
1010- (
1011- "Piano" ,
1012- & [
1013- "Für Elise" ,
1014- "Moonlight Sonata - I. Adagio sostenuto" ,
1015- "Clair de lune" ,
1016- "Ballade No. 1 in G minor, Op. 23" ,
1017- "Impromptu in G-flat major, D. 899" ,
1018- ] ,
1019- ) ,
1020- (
1021- "Strings" ,
1022- & [
1023- "Air on the G String" ,
1024- "Eine kleine Nachtmusik - I. Allegro" ,
1025- "Winter - I. Allegro non molto" ,
1026- "Swan Lake - Scene" ,
1027- ] ,
1028- ) ,
1029- ] ;
1030- for ( name, titles) in SETS {
1031- let _ = peer
1032- . client
1033- . mutate ( mutators:: create_playlist ( ( * name) . into ( ) ) ) ;
1034- peer. refresh ( ) ;
1035- let Some ( list) = peer. choices . iter ( ) . find_map ( |c| match & c. source {
1036- Source :: Playlist ( id, n) if n == name => Some ( * id) ,
1037- _ => None ,
1038- } ) else {
1039- continue ;
1040- } ;
1041- let ids: Vec < harken:: Id < harken:: tables:: Media > > = titles
1042- . iter ( )
1043- . filter_map ( |t| peer. items . iter ( ) . find ( |i| i. title == * t) )
1044- . map ( |i| i. id )
1045- . collect ( ) ;
1046- for id in ids {
1047- let _ = peer. client . mutate ( mutators:: add_to_playlist ( list, id) ) ;
1048- }
1049- peer. refresh ( ) ;
1050- }
1051- }
1052-
1053774 fn boot ( ) -> ( Self , Task < Message > ) {
1054775 // The demo signs nobody in and talks to nothing: it opens a peer, seeds
1055776 // it, and that is the whole application. Everything below about tokens
@@ -1058,7 +779,7 @@ impl App {
1058779 {
1059780 let login = Self :: demo_login ( ) ;
1060781 let mut peer = Peer :: open ( & login) ;
1061- Self :: seed ( & mut peer) ;
782+ seed :: seed ( & mut peer) ;
1062783 let app = App {
1063784 pane : Pane :: Tracks ,
1064785 cursors : [ 0 ; 2 ] ,
0 commit comments