diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2afe9be --- /dev/null +++ b/.clang-format @@ -0,0 +1,168 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: true + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + - Regex: '.*' + Priority: 3 + SortPriority: 0 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentGotoLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +... + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d692b55 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Build Artifacts +build/ \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..435a6f0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +# Used by Prettier to ignore certain files and folders completely. +# See https://prettier.io/docs/en/ignore.html for details. + +# Ignore build and system artifacts +build/ +cmake/ +contrib/ + +# Ignore all 3rd party libraries +**/bootstrap* +**/jquery* +**/modernizr* +**/sammy* diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..f27022b --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,20 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "semi": true, + "singleQuote": true, + "overrides": [ + { + "files": ["*.html"], + "options": { + "tabWidth": 2 + } + }, + { + "files": ["*.css"], + "options": { + "tabWidth": 2 + } + } + ] +} diff --git a/.travis.yml b/.travis.yml index 4b2afb9..b4d35ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,15 @@ language: c sudo: required dist: trusty -compiler: - - gcc - - clang +compiler: + - gcc + - clang before_install: - - sudo apt-get -qq update - - sudo apt-get install -y libmpdclient-dev cmake - - mkdir build - - cd build - - cmake -D CMAKE_BUILD_TYPE=DEBUG .. + - sudo apt-get -qq update + - sudo apt-get install -y libmpdclient-dev cmake + - mkdir build + - cd build + - cmake -D CMAKE_BUILD_TYPE=DEBUG .. script: make - diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..564c431 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,32 @@ +# Development Notes + +## Code Formatting + +The project has been formatted with [prettier.io](https://prettier.io/) for the HTML, JavaScript, CSS, and Markdown files. See the configuration file [.prettierrc.json](./.prettierrc.json) and the ignore file [.prettierignore](./.prettierignore) for details. If `prettier` is installed globally, there's no need to provide the various `npm`-type dependencies in the project. Various editors may provide plugins that can use this configuration without having to install `npm` and `prettier` manually. + +Manual Usage: + +```bash +> npx prettier --write . +``` + +The C source and header files have been formatted with `clang-format`. There's no easy way to manually execute the formatter on all of the C files at the same time. The clang format is based off of the 'Google' style with ajdustments to make the changes not as disruptive. See [.clang-format](./.clang-format) file for the formatting rules. Various editors should be able to automatically format the source on save. + +The only files formatted are the non-third party library files. + +Manual Usage: + +```bash +> clang-format -i -style=file +``` + +Manually formatted files: + +- http_server.c +- http_server.h +- json_encode.h +- mpd_client.c +- mpd_client.h +- ympd.c + +For help with the rules, see [Clang Format Configurator](https://zed0.co.uk/clang-format-configurator/) for an interactive tool and [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html) for the rules reference. diff --git a/README.md b/README.md index 1d7fb81..4f9a3c3 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,26 @@ ympd Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS - http://www.ympd.org ![ScreenShot](http://www.ympd.org/assets/ympd_github.png) -Dependencies ------------- - - libmpdclient 2: http://www.musicpd.org/libs/libmpdclient/ - - cmake 2.6: http://cmake.org/ - - OpenSSL: https://www.openssl.org/ +## Dependencies -Unix Build Instructions ------------------------ +- libmpdclient 2: http://www.musicpd.org/libs/libmpdclient/ +- cmake 2.6: http://cmake.org/ +- OpenSSL: https://www.openssl.org/ + +## Unix Build Instructions 1. install dependencies. cmake, libmpdclient (dev), and OpenSSL (dev) are available from all major distributions. -2. create build directory ```cd /path/to/src; mkdir build; cd build``` -3. create makefile ```cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr``` -4. build ```make``` -5. install ```sudo make install``` or just run with ```./ympd``` +2. create build directory `cd /path/to/src; mkdir build; cd build` +3. create makefile `cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr` +4. build `make` +5. install `sudo make install` or just run with `./ympd` + +## Run flags -Run flags ---------- ``` Usage: ./ympd [OPTION]... @@ -39,21 +37,23 @@ Usage: ./ympd [OPTION]... --help this help ``` -SSL Support ------------ +## SSL Support + To run ympd with SSL support: -- create a certificate (key and cert in the same file), example: +- create a certificate (key and cert in the same file), example: + ``` # openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 1000 -nodes # cat key.pem cert.pem > ssl.pem ``` -- tell ympd to use a webport using SSL and where to find the certificate: + +- tell ympd to use a webport using SSL and where to find the certificate: + ``` # ./ympd -w "ssl://8081:/path/to/ssl.pem" ``` -Copyright ---------- +## Copyright 2013-2014 diff --git a/htdocs/css/mpd.css b/htdocs/css/mpd.css index a5c6acc..c1e9d46 100644 --- a/htdocs/css/mpd.css +++ b/htdocs/css/mpd.css @@ -15,12 +15,10 @@ body { margin-bottom: 0; } - button { overflow: hidden; } - #volume-icon { float: left; margin-right: 10px; @@ -34,7 +32,7 @@ button { white-space: nowrap; } -#breadcrump > li > a{ +#breadcrump > li > a { cursor: pointer; } @@ -58,17 +56,17 @@ button { background-image: none; outline: 0; -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); color: #428bca; background-color: #fdfdfd; border-color: #adadad; } @media (max-width: 1199px) { -#btn-responsive-block > .btn { - padding: 6px 12px; - font-size: 14px; - border-radius: 4px; + #btn-responsive-block > .btn { + padding: 6px 12px; + font-size: 14px; + border-radius: 4px; } } @@ -80,14 +78,16 @@ h1 { white-space: nowrap; } -td:nth-child(4), th:nth-child(4) { +td:nth-child(4), +th:nth-child(4) { /* This *has* to be placed before any t[dh]:nth-last-child(2) for the override to work. */ min-width: 50%; } -td:nth-last-child(2), th:nth-last-child(2) { +td:nth-last-child(2), +th:nth-last-child(2) { text-align: right; width: 4em; } @@ -98,7 +98,8 @@ td:nth-last-child(2), th:nth-last-child(2) { display: block; } -td:nth-child(2), td:nth-child(3) { +td:nth-child(2), +td:nth-child(3) { min-width: 25%; max-width: 10em; @@ -108,21 +109,24 @@ td:nth-child(2), td:nth-child(3) { } @media only screen and (max-width: 600px) { - td:nth-child(2), td:nth-child(3) { - min-width: 0; - max-width: 0; - } - td:nth-child(4), th:nth-child(4) { - min-width: 10%; - white-space: normal; - } + td:nth-child(2), + td:nth-child(3) { + min-width: 0; + max-width: 0; + } + td:nth-child(4), + th:nth-child(4) { + min-width: 10%; + white-space: normal; + } } tbody { cursor: pointer; } -td:last-child, td:first-child { +td:last-child, +td:first-child { width: 30px; } @@ -149,9 +153,9 @@ button { } #trashmode span:last-child { - display:inline-block; - text-align:left; - width:2.8em; + display: inline-block; + text-align: left; + width: 2.8em; } #filter > a.active { diff --git a/htdocs/index.html b/htdocs/index.html index 1cf62cf..e8e7e04 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -1,65 +1,110 @@ - - - - - - + + + + + + - ympd + ympd - - - + + + - - - - - - + + + + + + +