Skip to content

Commit

Permalink
new v0.1.0
Browse files Browse the repository at this point in the history
- now accepts string and array as input
- better demo
  • Loading branch information
juanbrujo committed Jun 16, 2015
1 parent 8773cb3 commit cd31dc7
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 166 deletions.
49 changes: 30 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,56 @@ module.exports = function(grunt) {
" * <%= pkg.licenses[0].copyright %>\n" +
" */\n"
},
concat: {
dist: {
src: ["src/Sluggin.js"],
dest: "dist/Sluggin.js"
},
options: {
banner: "<%= meta.banner %>"
}
},
// concat: {
// dist: {
// src: ["src/Sluggin.js"],
// dest: "dist/Sluggin.js"
// },
// options: {
// banner: "<%= meta.banner %>"
// }
// },
jshint: {
files: ["src/Sluggin.js"],
options: {
jshintrc: ".jshintrc"
}
},
uglify: {
my_target: {
src: ["src/Sluggin.js"],
dest: "dist/Sluggin.min.js"
min: {
options: {
banner: "<%= meta.banner %>"
},
files: {
'dist/Sluggin.min.js': ['src/Sluggin.js']
}
},
options: {
banner: "<%= meta.banner %>"
normal: {
options: {
banner: "<%= meta.banner %>",
beautify: true,
mangle: false
},
files: {
'dist/Sluggin.js': ['src/Sluggin.js']
}
}
},
watch: {
options: {
livereload: true
},
scripts: {
files: ['src/*.js'],
tasks: ['uglify'],
files: ["src/*.js"],
tasks: ["uglify"],
options: {
spawn: false
}
},
html: {
files: ['demo/*.html'],
files: ["demo/*.html"],
},
tasks: ['default']
tasks: ["default"]
}
});

Expand All @@ -61,7 +72,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-watch");

grunt.registerTask("default", ["concat", "uglify"]);
grunt.registerTask("default", ["uglify"]);
grunt.registerTask("testjs", ["jshint"]);

};
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
###Use

**Strings:**
```
Sluggin( "I used to have ugly text. Now I just have 1." );
➤ i-used-to-have-ugly-text-now-i-just-have-1
Expand All @@ -27,8 +28,19 @@ Sluggin( "Früher habe ich hässlich Text. Jetzt habe ich nur noch 1." );
➤ fruher-habe-ich-hasslich-text-jetzt-habe-ich-nur-noch-1
```

**Array:**

**Thanks**
```
Sluggin( [
"I used to have ugly text. Now I just have 1.",
"Solía tener texto feo. Ahora sólo tengo 1.",
"J'ai l'habitude d'avoir un texte laid. Je dois maintenant juste 1.",
"Früher habe ich hässlich Text. Jetzt habe ich nur noch 1."
] );
➤ ["i-used-to-have-ugly-text-now-i-just-have-1", "solia-tener-texto-feo-ahora-solo-tengo-1", "jai-lhabitude-davoir-un-texte-laid-je-dois-maintenant-juste-1", "fruher-habe-ich-hasslich-text-jetzt-habe-ich-nur-noch-1"]
```

**Thanks:**

- [SpeakingURL](https://github.com/pid/speakingurl)
- [FriendURL](https://github.com/riverside/friendurl)
Expand Down
4 changes: 2 additions & 2 deletions Sluggin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"title": "Sluggin.js",
"homepage": "https://github.com/juanbrujo/Sluggin.js",
"description": "Converts string into websafe-friendly-clean piece of text",
"demo": "",
"demo": "http://juanbrujo.github.io/Sluggin.js/",
"keywords": [
"javascript",
"slug",
"pretty url",
"SEO"
],
"version": "0.0.4",
"version": "0.1.0",
"author": {
"name": "Jorge Epuñan H.",
"url": "https://github.com/juanbrujo",
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sluggin",
"version": "0.0.4",
"version": "0.1.0",
"homepage": "https://github.com/juanbrujo/Sluggin.js",
"authors": [
"Jorge Epuñan <juanbrujo@gmail.com>"
Expand Down
65 changes: 51 additions & 14 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="f3 f2-m mega-ns b db-ns mrs mrn-ns mbn ttu mtn pulse-letters">
</h1>
<p class="f5 f3-ns dib db-ns fw1 phs mbn mbx-ns aqua">
Converts string into websafe-friendly-clean piece of text
<small class="ws-nowrap db f5 mts mtm-ns">2.09kb (minified)</small>
<small class="ws-nowrap db f5 mts mtm-ns">2.4kb (minified)</small>
</p>
</div>
<div class="pvm">
Expand All @@ -42,27 +42,35 @@ <h1 class="f4 ttu book">Use</h1>
<div class="dtc v-mid">
<div class="mw7 center phm phl-ns tl tl-ns">
<h1 class="f4 ttu book">Live Demo</h1>
<hr>
<section class="f4 f3-ns list pln lh-copy">
<article class="pvs live-demo">
<input type="text" id="stringinput" placeholder="Enter a text" />
<input type="text" id="stringinput" placeholder="Text I want to transform!" style="width:60%" />
<button id="sluggifyinput">Sluggin-this</button>
<p id="slugginoutput">Output: </p>
</article>
</section>
<h1 class="f4 ttu book">Languages Demos</h1>
<hr>
<section class="f4 f3-ns list pln lh-copy">
<article class="pvs demos">
</article>
</section>
<h1 class="f4 ttu book">Array Demo</h1>
<hr>
<section class="f4 f3-ns list pln lh-copy">
<article class="pvs arraydemo">
</article>
</section>
</div>
</div>
</section>
</main>
<footer class="bg-white gray phm pvx pvxl-ns bt b--light-gray h-50">
<small class="f5 mw7 db center lh-copy">
<strong>Sluggin.js</strong> is released under <a href="//mit-license.org/">MIT License</a>
<strong><a href="https://github.com/juanbrujo/Sluggin.js">Sluggin.js</a></strong> is released under <a href="//mit-license.org/">MIT License</a>
<br class="dn db-ns">
&copy; 2015 - Jorge Epuñan H.
&copy; 2015 - Jorge Epuñan H. | <a href="http://www.twitter.com/csslab">@csslab</a>
</small>
</footer>

Expand All @@ -77,37 +85,47 @@ <h1 class="f4 ttu book">Languages Demos</h1>

but.addEventListener("click",function(){
var inpString = inp.value;
console.log(inpString)
out.innerHTML = "Output: " + Sluggin( inpString );

});

// LANGUAGES (STATIC) DEMOS

var EngText = "I used to have ugly text. Now I just have 1."
createDemoOutput("EN",EngText);
createDemoOutput("EN",EngText,".demos");
var SpaText = "Solía tener texto feo. Ahora sólo tengo 1."
createDemoOutput("ES",SpaText);
createDemoOutput("ES",SpaText,".demos");
var FreText = "J'ai l'habitude d'avoir un texte laid. Je dois maintenant juste 1."
createDemoOutput("FR",FreText);
createDemoOutput("FR",FreText,".demos");
var GerText = "Früher habe ich hässlich Text. Jetzt habe ich nur noch 1."
createDemoOutput("GR",GerText);
createDemoOutput("GR",GerText,".demos");

function createDemoOutput(lang,text){
function createDemoOutput(lang,text,className){
var inputTitle = createElement("h2", "[class:f3]", "Input: [" + lang + "]");
document.querySelector(".demos").appendChild( inputTitle );
document.querySelector(className).appendChild( inputTitle );

var title = createElement("p", "[class:f3]", text);
document.querySelector(".demos").appendChild( title );
document.querySelector(className).appendChild( title );

var outputTitle = createElement("h2", "[class:f3]", "Output:");
document.querySelector(".demos").appendChild( outputTitle );
document.querySelector(className).appendChild( outputTitle );

var slug = Sluggin( text ),
output = createElement("pre", "[class:f3]", slug);
document.querySelector(".demos").appendChild( output );
document.querySelector(className).appendChild( output );
}

// ARRAY (STATIC) DEMO

var arrayDemo = [
"I used to have ugly text. Now I just have 1.",
"Solía tener texto feo. Ahora sólo tengo 1.",
"J'ai l'habitude d'avoir un texte laid. Je dois maintenant juste 1.",
"Früher habe ich hässlich Text. Jetzt habe ich nur noch 1."
]
createDemoOutput("Array","['" + arrayDemo[0] + "','" + arrayDemo[1] + "','" + arrayDemo[2] + "','" + arrayDemo[3] + "']",".arraydemo");


function createElement(name, val, result) {
if (typeof name === "undefined") {
return false;
Expand Down Expand Up @@ -157,6 +175,25 @@ <h1 class="f4 ttu book">Languages Demos</h1>
return ret;
};

// TESTING VIA BROWSER'S CONSOLE
console.log("%c Sluggin.js \n Testing via browser's console ","background-color:#505074;color:white;");

// Test 1: output 1 string of text
console.info('Test 1: output 1 string of text:');
console.log( Sluggin("I used to have ugly text. Now I just have 1.") );

// Test 2: output an array of texts
console.info('Test 2: output an array of texts:');
console.log( Sluggin([
"I used to have ugly text. Now I just have 1.",
"Solía tener texto feo. Ahora sólo tengo 1.",
"J'ai l'habitude d'avoir un texte laid. Je dois maintenant juste 1.",
"Früher habe ich hässlich Text. Jetzt habe ich nur noch 1."
]) );

// Test 3: if input is an object, returns empty
console.log( Sluggin( document.querySelector("#stringinput") ) );

</script>
</body>
</html>

0 comments on commit cd31dc7

Please sign in to comment.