Skip to content

Commit 713827f

Browse files
committed
Tweaked some styles and started automated testing. Fixes BookStackApp#11.
1 parent 30d2edd commit 713827f

23 files changed

+254
-55
lines changed

app/Http/Controllers/BookController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function store(Request $request)
7070
$book->updated_by = Auth::user()->id;
7171
$book->save();
7272
Activity::add($book, 'book_create', $book->id);
73-
return redirect('/books');
73+
return redirect($book->getUrl());
7474
}
7575

7676
/**

app/Http/Controllers/ChapterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function store($bookSlug, Request $request)
6565
$chapter->updated_by = Auth::user()->id;
6666
$book->chapters()->save($chapter);
6767
Activity::add($chapter, 'chapter_create', $book->id);
68-
return redirect($book->getUrl());
68+
return redirect($chapter->getUrl());
6969
}
7070

7171
/**

app/Repos/BookRepo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public function getBySlug($slug)
3535
return $this->book->where('slug', '=', $slug)->first();
3636
}
3737

38+
/**
39+
* Get a new book instance from request input.
40+
* @param $input
41+
* @return Book
42+
*/
3843
public function newFromInput($input)
3944
{
4045
return $this->book->fill($input);

config/database.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@
6464
'strict' => false,
6565
],
6666

67+
'mysql_testing' => [
68+
'driver' => 'mysql',
69+
'host' => 'localhost',
70+
'database' => 'bookstack-test',
71+
'username' => 'bookstack-test',
72+
'password' => 'bookstack-test',
73+
'charset' => 'utf8',
74+
'collation' => 'utf8_unicode_ci',
75+
'prefix' => '',
76+
'strict' => false,
77+
],
78+
6779
'pgsql' => [
6880
'driver' => 'pgsql',
6981
'host' => env('DB_HOST', 'localhost'),

database/factories/ModelFactory.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,30 @@
1313

1414
$factory->define(Oxbow\User::class, function ($faker) {
1515
return [
16-
'name' => $faker->name,
17-
'email' => $faker->email,
18-
'password' => str_random(10),
16+
'name' => $faker->name,
17+
'email' => $faker->email,
18+
'password' => str_random(10),
1919
'remember_token' => str_random(10),
2020
];
2121
});
22+
23+
$factory->define(Oxbow\Book::class, function ($faker) {
24+
return [
25+
'name' => $faker->sentence,
26+
'description' => $faker->paragraph
27+
];
28+
});
29+
30+
$factory->define(Oxbow\Chapter::class, function ($faker) {
31+
return [
32+
'name' => $faker->sentence,
33+
'description' => $faker->paragraph
34+
];
35+
});
36+
37+
$factory->define(Oxbow\Page::class, function ($faker) {
38+
return [
39+
'name' => $faker->sentence,
40+
'html' => '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>'
41+
];
42+
});

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
<env name="CACHE_DRIVER" value="array"/>
2525
<env name="SESSION_DRIVER" value="array"/>
2626
<env name="QUEUE_DRIVER" value="sync"/>
27+
<env name="DB_CONNECTION" value="mysql_testing"/>
2728
</php>
2829
</phpunit>

resources/assets/sass/_buttons.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ $button-border-radius: 2px;
5151
}
5252
}
5353

54+
.text-button {
55+
@extend .link;
56+
background-color: transparent;
57+
padding: 0;
58+
margin: 0;
59+
border: none;
60+
&:focus, &:active {
61+
outline: 0;
62+
}
63+
}
64+
5465
.button-group {
5566
@include clearfix;
5667
.button, button[type="button"] {

resources/assets/sass/_text.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ h1, h2, h3, h4 {
4343
/*
4444
* Link styling
4545
*/
46-
a {
46+
a, .link {
4747
color: $primary;
4848
cursor: pointer;
4949
text-decoration: none;
5050
transition: color ease-in-out 80ms;
51+
font-family: $text;
52+
line-height: 1.6;
5153
&:hover {
5254
text-decoration: underline;
5355
color: darken($primary, 20%);

resources/assets/sass/styles.scss

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ h1, h2, h3, h4, h5, h6 {
309309
}
310310

311311
.faded {
312-
a {
312+
a, button, span {
313313
color: #666;
314+
}
315+
.text-button {
314316
opacity: 0.5;
315317
transition: all ease-in-out 120ms;
316318
&:hover {
@@ -324,12 +326,9 @@ h1, h2, h3, h4, h5, h6 {
324326
color: #000;
325327
font-size: 0.9em;
326328
background-color: rgba(21, 101, 192, 0.15);
327-
a, span {
328-
color: #000;
329-
}
330329
}
331330

332-
.breadcrumbs a, .action-buttons a {
331+
.breadcrumbs .text-button, .action-buttons .text-button {
333332
display: inline-block;
334333
padding: $-s;
335334
&:last-child {
@@ -340,7 +339,7 @@ h1, h2, h3, h4, h5, h6 {
340339
text-align: right;
341340
&.text-left {
342341
text-align: left;
343-
a {
342+
.text-button {
344343
padding-right: $-m;
345344
padding-left: 0;
346345
}

resources/views/books/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<div class="col-md-6 faded">
1010
<div class="action-buttons">
1111
@if($currentUser->can('book-create'))
12-
<a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a>
12+
<a href="/books/create" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>Add new book</a>
1313
@endif
1414
</div>
1515
</div>

0 commit comments

Comments
 (0)