Skip to content

Commit d8a505f

Browse files
committed
refactor code, update sample files
1 parent bcdcd78 commit d8a505f

23 files changed

+379
-330
lines changed

code-samples/clojure-sample.clj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(ns com.clojurebook.url-shortener
2+
(:require (compojure handler route)
3+
[ring.util.response :as response]))
4+
5+
(defn retain
6+
[& [url id :as args]]
7+
(if-let [id (apply shorten! args)]
8+
{:status 201
9+
:headers {"Location" id}
10+
:body (format "URL %s assigned the short identifier %s" url id)}
11+
{:status 409 :body (format "Short URL %s is already taken" id)}))
12+
13+
(defroutes app*
14+
(GET "/" request "Welcome!")
15+
(PUT "/:id" [id url] (retain url id))
16+
(POST "/" [url] (if (empty? url)
17+
{:status 400 :body "No `url` parameter provided"}
18+
(retain url)))
19+
(GET "/:id" [id] (redirect id))
20+
(GET "/list/" [] (interpose "\n" (keys @mappings)))
21+
(compojure.route/not-found "Sorry, there's nothing here."))
22+
23+
(def app (compojure.handler/api app*))
24+
25+
;; ; To run locally:
26+
;; (use '[ring.adapter.jetty :only (run-jetty)])
27+
;; (def server (run-jetty #'app {:port 8080 :join? false}))

code-samples/clojure.clj

Lines changed: 0 additions & 72 deletions
This file was deleted.

code-samples/css-sample.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ a {
1515
text-decoration: none;
1616
cursor: pointer;
1717
outline: 0; }
18+
19+
.my-class {
20+
21+
}

code-samples/erb.erb renamed to code-samples/erb-sample.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<%= render 'layouts/header' %>
1313
<div class="container">
1414
<% flash.each do |key, value| %>
15-
<div class="alert alert-<%= key %>"><%= value %></div>
15+
<div class="alert alert-<%= key %>"> <%= value %> </div>
1616
<% end %>
1717
<%= yield %>
1818
<%= render 'layouts/footer' %>

code-samples/gf-markdown-test.md

Lines changed: 0 additions & 78 deletions
This file was deleted.

code-samples/github-markdown-sample.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,83 @@ She packed her seven *versalia*, put her initial into the belt and made herself
2626
#### Important paragraph
2727
Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A bold **river** named Duden flows by their place and supplies it with the necessary regelialia. ~~Here is some stroked text.~~
2828
The copy warned the Little Blind Text, that where it came from it would have been rewritten a thousand times and everything that was left from its origin would be the word "and" and the Little Blind Text should turn around and return to its own, safe country.
29+
30+
31+
# H1
32+
## H2
33+
### H3
34+
#### H4
35+
##### H5
36+
###### H6
37+
38+
Emphasis, aka italics, with *asterisks* or _underscores_.
39+
40+
Strong emphasis, aka bold, with **asterisks** or __underscores__.
41+
42+
Combined emphasis with **asterisks and _underscores_**.
43+
44+
Strikethrough uses two tildes. ~~Scratch this~~.
45+
46+
[I'm an inline-style link](https://www.google.com)
47+
48+
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
49+
50+
[I'm a reference-style link][Arbitrary case-insensitive reference text]
51+
52+
[I'm a relative reference to a repository file](../blob/master/LICENSE)
53+
54+
[You can use numbers for reference-style link definitions][1]
55+
56+
Or leave it empty and use the [link text itself].
57+
58+
URLs and URLs in angle brackets will automatically get turned into links.
59+
http://www.example.com or <http://www.example.com> and sometimes
60+
example.com (but not on Github, for example).
61+
62+
Some text to show that the reference links can follow later.
63+
64+
[arbitrary case-insensitive reference text]: https://www.mozilla.org
65+
[1]: http://slashdot.org
66+
[link text itself]: http://www.reddit.com
67+
68+
Here's our logo (hover to see the title text):
69+
70+
Inline-style:
71+
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
72+
73+
Reference-style:
74+
![alt text][logo]
75+
76+
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
77+
78+
Inline `code` has `back-ticks around` it.
79+
80+
```javascript
81+
var s = "JavaScript syntax highlighting";
82+
alert(s);
83+
```
84+
85+
```python
86+
s = "Python syntax highlighting"
87+
print s
88+
```
89+
90+
```
91+
No language indicated, so no syntax highlighting.
92+
But let's throw in a <b>tag</b>.
93+
```
94+
95+
> Blockquotes are very handy in email to emulate reply text.
96+
> This line is part of the same quote.
97+
98+
Quote break.
99+
100+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure ![alt text][logo] this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
101+
102+
<dl>
103+
<dt>Definition list</dt>
104+
<dd>Is something people use sometimes.</dd>
105+
106+
<dt>Markdown in HTML</dt>
107+
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
108+
</dl>
File renamed without changes.

code-samples/js.js renamed to code-samples/javascript-sample.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2+
// 1. Example ----------------------
3+
4+
var Sales = "Toyota";
5+
6+
function CarTypes(name) {
7+
if (name == "Honda") {
8+
return name;
9+
} else {
10+
return "Sorry, we don't sell " + name + ".";
11+
}
12+
}
13+
14+
var car = { myCar: "Saturn", getCar: CarTypes("Honda"), special: Sales };
15+
16+
console.log(car.special);
17+
118
clone: function (o) {
219
var type = _.util.type(o);
320

code-samples/json-sample.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[
2+
{ "1.": "Example" },
3+
{
4+
"widget": {
5+
"debug": "on",
6+
"window": {
7+
"title": "Sample Konfabulator Widget",
8+
"name": "main_window",
9+
"width": 500,
10+
"height": 500
11+
},
12+
"image": {
13+
"src": "Images/Sun.png",
14+
"name": "sun1",
15+
"hOffset": 250,
16+
"vOffset": 250,
17+
"alignment": "center"
18+
},
19+
"text": {
20+
"data": "Click Here",
21+
"size": 36,
22+
"style": "bold",
23+
"name": "text1",
24+
"hOffset": 250,
25+
"vOffset": 100,
26+
"alignment": "center",
27+
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
28+
}
29+
}
30+
},
31+
32+
33+
{ "2.": "Tests" },
34+
{
35+
"count": [17500, null, "String"],
36+
"description": {"text": "She said, \"Hello\"", "sensitive": false}
37+
},
38+
{
39+
"deeply_nested": {
40+
"key": {
41+
"key": {
42+
"key": {
43+
"array": [1, "two", null, "asdf", "sadf"],
44+
"string": "hello"
45+
}
46+
}
47+
}
48+
}
49+
},
50+
{
51+
//"comment": "test",
52+
"proper-comment": "JSON doesn't allow for comments, and the two slash characters on the line above should be rendered as invalid entities"
53+
}
54+
]
File renamed without changes.

0 commit comments

Comments
 (0)