├── .gitignore ├── vendor ├── jquery.min.js └── prettify.js ├── public ├── images │ └── img.png ├── jsprint.css ├── jsprint.css.map ├── jsprint.js.map ├── jsprint.js └── index.html ├── app ├── assets │ ├── images │ │ └── img.png │ └── index.html ├── utils.coffee ├── config.coffee ├── styles │ ├── jsprint.css │ ├── prettify-desert.css │ └── theme.css └── app.coffee ├── bower.json ├── config.coffee ├── Makefile ├── package.json ├── tools ├── htmlconverter │ └── htmlconvert.html └── jsprint_old.js ├── coffeelint.json ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components/ 2 | node_modules/ 3 | 4 | -------------------------------------------------------------------------------- /vendor/jquery.min.js: -------------------------------------------------------------------------------- 1 | ../bower_components/jquery/dist/jquery.min.js -------------------------------------------------------------------------------- /public/images/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kursion/jsprint/HEAD/public/images/img.png -------------------------------------------------------------------------------- /app/assets/images/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kursion/jsprint/HEAD/app/assets/images/img.png -------------------------------------------------------------------------------- /app/utils.coffee: -------------------------------------------------------------------------------- 1 | module.exports = exp = {} 2 | 3 | exp.appendToClass = appendToClass = (className, content) -> 4 | $(".#{className}").append(content) 5 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsprint", 3 | "version": "0.1.0", 4 | "main": "release/jsprint.js", 5 | "dependencies": { 6 | "jquery": "~2.1.1" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /config.coffee: -------------------------------------------------------------------------------- 1 | # Brunch.io configuration file 2 | {name} = require './package' 3 | 4 | exports.config = 5 | modules: 6 | nameCleaner: (path) -> 7 | path.replace /^app/, name 8 | 9 | path: 10 | public: 'public' 11 | files: 12 | javascripts: 13 | joinTo: 14 | 'vendor.js': /^vendor/ 15 | 'jsprint.js': /^app/ 16 | stylesheets: 17 | joinTo: 'jsprint.css': /^app\/styles/ 18 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | @echo "Build the project (BRUNCH)" 3 | @./node_modules/brunch/bin/brunch build 4 | watch: 5 | @echo "Running the watcher (BRUNCH)" 6 | @./node_modules/brunch/bin/brunch watch --server 7 | install: 8 | #@echo "Installing brunch & bower (NPM)" 9 | #@sudo npm install -g brunch 10 | #@sudo npm install -g bower 11 | @echo "Installing brunch dependencies (NPM)" 12 | @npm install 13 | @bower install 14 | clean: 15 | @cd release/;rm -rf *;cd .. 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Yves Lange", 3 | "name": "jsprint", 4 | "description": "Creates printable documents", 5 | "version": "0.0.1", 6 | "homepage": "https://github.com/kursion/jsprint", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/kursion/jsprint" 10 | }, 11 | "dependencies": {}, 12 | "devDependencies": { 13 | "brunch": "1.7.14", 14 | "bower": "1.3.3", 15 | "javascript-brunch": ">= 1.0 < 1.8", 16 | "coffee-script-brunch": ">= 1.0 < 1.8", 17 | "css-brunch": ">= 1.0 < 1.8", 18 | "uglify-js-brunch": ">= 1.0 < 1.8", 19 | "clean-css-brunch": ">= 1.0 < 1.8", 20 | "auto-reload-brunch": ">= 1.0 < 1.8", 21 | "less-brunch": "~1.5.2" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/config.coffee: -------------------------------------------------------------------------------- 1 | module.exports = exp = {} 2 | 3 | exp.Main = class Main 4 | VERSION = "1.2" 5 | 6 | CLASS = 7 | "title": "jsprint-title" 8 | "page": "jsprint-page" 9 | "header": "jsprint-page-header" 10 | "footer": "jsprint-page-footer" 11 | "summary": "jsprint-summary" 12 | "bibliography": "jsprint-bibliography" 13 | "imageography": "jsprint-imageography" 14 | "footer-pagenbr": "jsprint-pagenbr" 15 | "def-header": "jsprint-def-header" 16 | "page-summary": "jsprint-page-summary" 17 | "summary-entry": "jsprint-summary-entry" 18 | "img-legend": "jsprint-img-legend" 19 | 20 | CONFIG = 21 | summary: 22 | nbrtitle: 45 23 | 24 | constructor: -> null 25 | 26 | getClass: (className) -> CLASS[className] 27 | 28 | getClasses: -> [k] for k, v of CLASS 29 | 30 | getVersion: -> VERSION 31 | 32 | get: (configName, option) -> CONFIG[configName][option] 33 | -------------------------------------------------------------------------------- /app/styles/jsprint.css: -------------------------------------------------------------------------------- 1 | body{ 2 | width: 200mm; 3 | margin: auto; 4 | } 5 | 6 | *{ 7 | -webkit-print-color-adjust:exact; 8 | } 9 | pre{ 10 | -webkit-print-color-adjust:economy; 11 | } 12 | 13 | /* Header */ 14 | .jsprint-page-header{ 15 | text-align: right; 16 | margin-top: 10px; 17 | } 18 | .jsprint-def-header{ display: none; } 19 | .jsprint-page-header{ 20 | postition: absolute; 21 | top: 0px; 22 | } 23 | 24 | /* Summary */ 25 | .jsprint-summary-entry{ border-bottom: #afafaf 1px dotted; } 26 | .jsprint-summary-H1{ font-size: 1.2em; font-weight: bold; } 27 | .jsprint-summary-H2{ font-size: 1.1em; padding-left: 10px; } 28 | .jsprint-summary-H3{ font-size: 1em; padding-left: 20px; } 29 | .jsprint-summary-H4{ font-size: 0.9em; padding-left: 30px; } 30 | .jsprint-summary-entry div{ width: 20px; float: right; } 31 | 32 | /* Page content */ 33 | 34 | .jsprint-page{ 35 | padding-left: 20px; 36 | padding-right: 25px; 37 | page-break-after: always; 38 | height: 290mm; 39 | position: relative; 40 | } 41 | 42 | .jsprint-summary{ 43 | padding-top: 20px; 44 | } 45 | 46 | .jsprint-page-footer{ 47 | position: absolute; 48 | bottom: 0px; 49 | right: 1px; 50 | } 51 | .jsprint-page-footer .jsprint-pagenbr{ 52 | width: 20px; 53 | padding-right: 10px; 54 | padding-bottom: 10px; 55 | } 56 | .jsprint-img-legend{ 57 | text-align: center; 58 | font-style: italic; 59 | } 60 | -------------------------------------------------------------------------------- /app/styles/prettify-desert.css: -------------------------------------------------------------------------------- 1 | /* desert scheme ported from vim to google prettify */ 2 | pre.prettyprint { display: block; background-color: #333 } 3 | pre .nocode { background-color: none; color: #000 } 4 | pre .str { color: #ffa0a0 } /* string - pink */ 5 | pre .kwd { color: #f0e68c; font-weight: bold } 6 | pre .com { color: #87ceeb } /* comment - skyblue */ 7 | pre .typ { color: #98fb98 } /* type - lightgreen */ 8 | pre .lit { color: #cd5c5c } /* literal - darkred */ 9 | pre .pun { color: #fff } /* punctuation */ 10 | pre .pln { color: #fff } /* plaintext */ 11 | pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */ 12 | pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */ 13 | pre .atv { color: #ffa0a0 } /* attribute value - pink */ 14 | pre .dec { color: #98fb98 } /* decimal - lightgreen */ 15 | 16 | /* Specify class=linenums on a pre to get line numbering */ 17 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */ 18 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 19 | /* Alternate shading for lines */ 20 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 21 | 22 | @media print { 23 | pre.prettyprint { background-color: none } 24 | pre .str, code .str { color: #060 } 25 | pre .kwd, code .kwd { color: #006; font-weight: bold } 26 | pre .com, code .com { color: #600; font-style: italic } 27 | pre .typ, code .typ { color: #404; font-weight: bold } 28 | pre .lit, code .lit { color: #044 } 29 | pre .pun, code .pun { color: #440 } 30 | pre .pln, code .pln { color: #000 } 31 | pre .tag, code .tag { color: #006; font-weight: bold } 32 | pre .atn, code .atn { color: #404 } 33 | pre .atv, code .atv { color: #060 } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /tools/htmlconverter/htmlconvert.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 9 | 10 | 11 | 12 | 24 | 25 | 62 | 63 | -------------------------------------------------------------------------------- /coffeelint.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrow_spacing": { 3 | "level": "ignore" 4 | }, 5 | "camel_case_classes": { 6 | "level": "error" 7 | }, 8 | "coffeescript_error": { 9 | "level": "error" 10 | }, 11 | "colon_assignment_spacing": { 12 | "level": "ignore", 13 | "spacing": { 14 | "left": 0, 15 | "right": 0 16 | } 17 | }, 18 | "cyclomatic_complexity": { 19 | "value": 10, 20 | "level": "ignore" 21 | }, 22 | "duplicate_key": { 23 | "level": "error" 24 | }, 25 | "empty_constructor_needs_parens": { 26 | "level": "ignore" 27 | }, 28 | "indentation": { 29 | "value": 2, 30 | "level": "error" 31 | }, 32 | "line_endings": { 33 | "level": "ignore", 34 | "value": "unix" 35 | }, 36 | "max_line_length": { 37 | "value": 96, 38 | "level": "warn", 39 | "limitComments": true 40 | }, 41 | "missing_fat_arrows": { 42 | "level": "ignore" 43 | }, 44 | "newlines_after_classes": { 45 | "value": 3, 46 | "level": "ignore" 47 | }, 48 | "no_backticks": { 49 | "level": "error" 50 | }, 51 | "no_debugger": { 52 | "level": "warn" 53 | }, 54 | "no_empty_functions": { 55 | "level": "ignore" 56 | }, 57 | "no_empty_param_list": { 58 | "level": "ignore" 59 | }, 60 | "no_implicit_braces": { 61 | "level": "ignore", 62 | "strict": true 63 | }, 64 | "no_implicit_parens": { 65 | "strict": true, 66 | "level": "ignore" 67 | }, 68 | "no_interpolation_in_single_quotes": { 69 | "level": "ignore" 70 | }, 71 | "no_plusplus": { 72 | "level": "ignore" 73 | }, 74 | "no_stand_alone_at": { 75 | "level": "ignore" 76 | }, 77 | "no_tabs": { 78 | "level": "error" 79 | }, 80 | "no_throwing_strings": { 81 | "level": "error" 82 | }, 83 | "no_trailing_semicolons": { 84 | "level": "error" 85 | }, 86 | "no_trailing_whitespace": { 87 | "level": "error", 88 | "allowed_in_comments": false, 89 | "allowed_in_empty_lines": true 90 | }, 91 | "no_unnecessary_double_quotes": { 92 | "level": "ignore" 93 | }, 94 | "no_unnecessary_fat_arrows": { 95 | "level": "warn" 96 | }, 97 | "non_empty_constructor_needs_parens": { 98 | "level": "ignore" 99 | }, 100 | "space_operators": { 101 | "level": "ignore" 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /app/styles/theme.css: -------------------------------------------------------------------------------- 1 | /*****************************************************/ 2 | /* General customization */ 3 | /*****************************************************/ 4 | body{ 5 | font-family: arial; 6 | } 7 | h1{ 8 | color: #D5BB94; 9 | margin: 0px; 10 | margin-bottom: 10px; 11 | } 12 | h2{ 13 | padding-top: 20px; 14 | color: #F8BA1C; 15 | font-size: 20px; 16 | padding-left: 5px; 17 | margin: 0px; 18 | font-style: italic; 19 | margin-bottom: 10px; 20 | } 21 | h3{ 22 | color: #EABB7A; 23 | font-size: 16px; 24 | padding-left: 10px; 25 | margin: 0px; 26 | font-style: italic; 27 | } 28 | h4{ 29 | color: #EBCC9A; 30 | font-size: 14px; 31 | padding-left: 10px; 32 | margin: 0px; 33 | font-style: italic; 34 | } 35 | p{ 36 | font-size: 14px; 37 | text-align: justify; 38 | } 39 | 40 | ul{ 41 | list-style: none; 42 | padding: 0; 43 | margin: 0; 44 | } 45 | 46 | 47 | li{ 48 | padding-left: 1em; 49 | text-indent: -.7em; 50 | font-size: 14px; 51 | margin-bottom: 5px; 52 | } 53 | li:before{ 54 | color: #B09367; 55 | content: "• "; 56 | } 57 | 58 | a{ 59 | color: #7f7f7f; 60 | font-style: italic; 61 | text-decoration: none; 62 | } 63 | 64 | table{ 65 | border-spacing:0; 66 | border: #cfcfcf 1px solid; 67 | margin: auto; 68 | } 69 | 70 | table tr th{ 71 | background-color: #C3AD7A; 72 | color: #fefefe; 73 | font-size: 14px; 74 | text-align: left; 75 | 76 | } 77 | table tr td{ 78 | font-size: 12px; 79 | margin: 0px; 80 | color: #5f5f5f; 81 | padding: 2px 10px; 82 | } 83 | table tr:nth-child(even) {background: #CCC} 84 | 85 | img{ 86 | width: 95%; 87 | margin: 0 auto; 88 | display: block; 89 | border: #cfcfcf 1px solid; 90 | padding: 5px 5px; 91 | } 92 | 93 | pre{ 94 | background-color: #3f3f3f; 95 | color: #efefef; 96 | } 97 | 98 | 99 | 100 | 101 | /*****************************************************/ 102 | /* JSP Customization */ 103 | /*****************************************************/ 104 | 105 | /* Page border */ 106 | .jsprint-page{ border: #cecece 1px solid; } 107 | 108 | 109 | /* Page number color */ 110 | .jsprint-page-footer .jsprint-pagenbr{ color: #9f9f9f; } 111 | 112 | 113 | /* Summary color */ 114 | .jsprint-summary{ color: #9f9f9f; } 115 | 116 | 117 | /* Header */ 118 | .jsprint-page-header p{ 119 | text-align: right; 120 | color: #9f9f9f; 121 | border-bottom: #dfdfdf 1px solid; 122 | padding-bottom: 5px; 123 | } 124 | 125 | 126 | /* Image legend style */ 127 | .jsprint-img-legend{ 128 | color: #9f9f9f; 129 | font-size: 0.7em; 130 | } 131 | 132 | /*****************************************************/ 133 | /* JSP Personalization */ 134 | /*****************************************************/ 135 | 136 | p.note{ 137 | background-color: #cfcfcf; 138 | border: #9f9f9f 2px solid; 139 | padding: 5px; 140 | border-top: 0; 141 | border-bottom: 0; 142 | font-style: italic; 143 | color: #3f3f3f; 144 | } 145 | -------------------------------------------------------------------------------- /app/app.coffee: -------------------------------------------------------------------------------- 1 | M = { 2 | config: require 'jsprint/config' 3 | utils: require 'jsprint/utils' 4 | } 5 | 6 | class Jsprint 7 | # Configuration for Jsprint 8 | CONFIG = new M.config.Main() 9 | 10 | constructor: () -> 11 | console.info? "Jsprint version:", CONFIG.getVersion() 12 | @init() 13 | 14 | init: -> 15 | @renderImgLegends() 16 | @renderHeader() 17 | @renderFooter() 18 | @renderLinkReferences() 19 | @createSummary() 20 | 21 | createSummary: -> 22 | # Generating tags 23 | 24 | # TODO: test new method 25 | # tags = [] 26 | # tagsCounter = {} 27 | # for i in [1..10] 28 | # tags.push "H#{i}" 29 | # tagsCounter["H#{i}"] ||= 0 30 | # tagsCounter["H#{i}"]++ 31 | # 32 | # console.log tags, tagsCounter 33 | # console.log tags.join(" ") 34 | # $("." + CONFIG.getClass("page")).each((i, page) -> 35 | # console.log i, page 36 | # $(tags.join(" ")).each( -> 37 | # console.log i 38 | # ) 39 | # ) 40 | 41 | # ----------------- Old 42 | nbrtitle = undefined 43 | pagenbr = undefined 44 | JSP_TITLE_NBR = 0 45 | JSP_TITLE2_NBR = 0 46 | JSP_TITLE3_NBR = 0 47 | JSP_TITLE4_NBR = 0 48 | pagenbr = 0 49 | nbrtitle = 0 50 | header = @_getHeader() 51 | $("." + CONFIG.getClass("page")).each (i, page) -> 52 | pagenbr++ 53 | $(page).find("." + CONFIG.getClass("title")).each (_, title) -> 54 | h_nbr = undefined 55 | t = undefined 56 | tag = undefined 57 | t = $(title).text() 58 | tag = $(this)[0].tagName 59 | h_nbr = "" 60 | nbrtitle++ 61 | if tag is "H1" 62 | JSP_TITLE_NBR++ 63 | JSP_TITLE2_NBR = 0 64 | h_nbr = JSP_TITLE_NBR 65 | if tag is "H2" 66 | JSP_TITLE2_NBR++ 67 | JSP_TITLE3_NBR = 0 68 | h_nbr = JSP_TITLE_NBR + "." + JSP_TITLE2_NBR 69 | if tag is "H3" 70 | JSP_TITLE3_NBR++ 71 | JSP_TITLE4_NBR = 0 72 | h_nbr = JSP_TITLE_NBR + "." + JSP_TITLE2_NBR + "." + JSP_TITLE3_NBR 73 | if tag is "H4" 74 | JSP_TITLE4_NBR++ 75 | h_nbr = JSP_TITLE_NBR + "." + JSP_TITLE2_NBR + "." + 76 | JSP_TITLE3_NBR + "." + JSP_TITLE4_NBR 77 | $(title).text h_nbr + " " + t 78 | if nbrtitle % CONFIG.get("summary", "nbrtitle") is 0 79 | $("." + CONFIG.getClass("page-summary")) 80 | .last().after "