-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new font and many other changes
- Loading branch information
Showing
30 changed files
with
497 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright © 2022 Philipp Hochkamp <git@phochkamp.de> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/thexyno/xynoblog/db" | ||
) | ||
|
||
// / publishCmd represents the publish command | ||
var publishCmd = &cobra.Command{ | ||
Use: "publish", | ||
Short: "Publishes posts (sets draft to false)", | ||
Long: ``, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
dbc := db.NewDb(viper.GetString(dbURIKey)) | ||
dbc.Seed() | ||
for _, arg := range args { | ||
if err := dbc.Publish(arg); err != nil { | ||
log.Error(err) | ||
} | ||
} | ||
|
||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(publishCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// addCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// addCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright © 2022 Philipp Hochkamp <git@phochkamp.de> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/thexyno/xynoblog/db" | ||
) | ||
|
||
var seedCmd = &cobra.Command{ | ||
Use: "seed", | ||
Short: "Update database schema", | ||
Long: ``, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
dbc := db.NewDb(viper.GetString(dbURIKey)) | ||
dbc.Seed() | ||
log.Info("Seeded database") | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(seedCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// addCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// addCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- +migrate Up | ||
ALTER TABLE posts ADD COLUMN draft BOOLEAN NOT NULL DEFAULT TRUE; | ||
UPDATE posts SET draft = FALSE; | ||
|
||
-- +migrate Down | ||
ALTER TABLE posts DROP COLUMN draft; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- +migrate Up | ||
PRAGMA foreign_keys = ON; | ||
CREATE TEMPORARY TABLE post_tags_backup AS SELECT * FROM post_tags; | ||
DROP TABLE post_tags; | ||
CREATE TABLE post_tags ( | ||
post_id TEXT NOT NULL, | ||
tag TEXT NOT NULL, | ||
FOREIGN KEY (post_id) REFERENCES posts (post_id) ON DELETE CASCADE, | ||
PRIMARY KEY (post_id, tag) | ||
); | ||
INSERT INTO post_tags (post_id, tag) SELECT post_id, tag FROM post_tags_backup; | ||
DROP TABLE post_tags_backup; | ||
|
||
-- +migrate Down | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
-- name: GetPostsNoContent :many | ||
select post_id, title, created_at, updated_at from posts order by created_at desc limit ? offset ?; | ||
select post_id, title, created_at, updated_at from posts where draft = FALSE order by created_at desc limit ? offset ?; | ||
|
||
-- name: GetPosts :many | ||
select post_id, title, content, created_at, updated_at from posts order by created_at desc limit ? offset ?; | ||
select post_id, title, content, created_at, updated_at from posts where draft = FALSE order by created_at desc limit ? offset ?; | ||
-- name: GetPostsWithTags :many | ||
select posts.post_id, title, content, created_at, updated_at, tag from posts join post_tags on posts.post_id = post_tags.post_id group by posts.post_id order by created_at desc limit ? offset ?; | ||
select posts.post_id, title, content, created_at, updated_at, tag from posts join post_tags on posts.post_id = post_tags.post_id where draft = FALSE group by posts.post_id order by created_at desc limit ? offset ?; | ||
-- name: GetPostsByTag :many | ||
select posts.post_id, title, content, created_at, updated_at, tag from posts join post_tags on posts.post_id = post_tags.post_id where tag = ? and draft = FALSE order by created_at desc limit ? offset ?; | ||
-- name: GetPostsByTagNoContent :many | ||
select posts.post_id, title, created_at, updated_at, tag from posts join post_tags on posts.post_id = post_tags.post_id where tag = ? and draft = FALSE order by created_at desc limit ? offset ?; | ||
|
||
-- name: GetPostIds :many | ||
select post_id, updated_at from posts; | ||
select post_id, updated_at from posts where draft = FALSE; | ||
|
||
-- name: GetPost :one | ||
select post_id, title, content, created_at, updated_at from posts where post_id = ?; | ||
select post_id, title, content, created_at, updated_at, draft from posts where post_id = ?; | ||
|
||
-- name: GetTags :many | ||
select tag from post_tags where post_id = ?; | ||
|
||
-- name: AddPost :one | ||
insert into posts (post_id,title,content,created_at,updated_at) values (?,?,?,?,?) returning *; | ||
insert into posts (post_id,title,content,created_at,updated_at,draft) values (?,?,?,?,?,?) returning *; | ||
-- name: UpdatePost :exec | ||
update posts set post_id = ?,title = ?,content = ?,created_at = ?,updated_at = ? where post_id = ?; | ||
update posts set post_id = ?,title = ?,content = ?,created_at = ?,updated_at = ?, draft = ? where post_id = ?; | ||
-- name: AddTag :one | ||
insert into post_tags (post_id, tag) values (?,?) returning *; | ||
-- name: DeleteTags :exec | ||
delete from post_tags where post_id = ?; | ||
-- name: PublishPost :exec | ||
update posts set draft = FALSE, created_at = datetime(), updated_at = datetime() where post_id = ?; |
Oops, something went wrong.