diff --git a/extra/db/info/info.factor b/extra/db/info/info.factor new file mode 100644 index 0000000000..66409f2834 --- /dev/null +++ b/extra/db/info/info.factor @@ -0,0 +1,15 @@ +USING: accessors sequences generalizations io.encodings.utf8 db.postgresql parser combinators vocabs.parser db.sqlite +io.files ; +IN: db.info +! having sensative (and likely to change) information directly in source code seems a bad idea +: get-info ( -- lines ) current-vocab name>> "vocab:" "/dbinfo.txt" surround utf8 file-lines ; +SYNTAX: get-psql-info get-info 5 firstn + { + [ >>host ] + [ >>port ] + [ >>username ] + [ [ f ] [ ] if-empty >>password ] + [ >>database ] + } spread parsed ; + +SYNTAX: get-sqlite-info get-info first parsed ; \ No newline at end of file diff --git a/extra/persistency/persistency.factor b/extra/persistency/persistency.factor index 8100bce353..1604c66b40 100644 --- a/extra/persistency/persistency.factor +++ b/extra/persistency/persistency.factor @@ -22,4 +22,4 @@ SYNTAX: STORED-TUPLE: parse-tuple-definition [ drop persistent ] dip [ remove-ty : get-tuple ( query -- tuple ) [ select-tuple ] w/db ; : store-tuple ( tuple -- ) [ insert-tuple ] w/db ; : modify-tuple ( tuple -- ) [ update-tuple ] w/db ; -: remove-tuples ( tuple -- ) [ delete-tuples ] w/db ; +: remove-tuples ( tuple -- ) [ delete-tuples ] w/db ; \ No newline at end of file diff --git a/extra/recipes/recipes.factor b/extra/recipes/recipes.factor index 4ad9397504..528663d370 100644 --- a/extra/recipes/recipes.factor +++ b/extra/recipes/recipes.factor @@ -1,5 +1,5 @@ USING: accessors arrays colors.constants combinators db.queries -db.sqlite db.tuples db.types io.files.temp kernel locals math +db.info db.tuples db.types kernel locals math monads persistency sequences sequences.extras ui ui.frp.gadgets ui.frp.layout ui.frp.signals ui.gadgets.labels ui.gadgets.scrollers ui.pens.solid ; @@ -8,7 +8,7 @@ IN: recipes STORED-TUPLE: recipe { title { VARCHAR 100 } } { votes INTEGER } { txt TEXT } { genre { VARCHAR 100 } } ; : ( title genre text -- recipe ) recipe new swap >>txt swap >>genre swap >>title 0 >>votes ; -"recipes.db" temp-file recipe define-db +get-psql-info recipe define-db : top-recipes ( offset search -- recipes ) T{ recipe } rot >>title >>tuple "votes" >>order 30 >>limit swap >>offset get-tuples ; : top-genres ( -- genres ) f f top-recipes [ genre>> ] map prune 4 (head-slice) ; diff --git a/extra/ui/frp/gadgets/gadgets.factor b/extra/ui/frp/gadgets/gadgets.factor index f39ca3accd..59dfd987a8 100644 --- a/extra/ui/frp/gadgets/gadgets.factor +++ b/extra/ui/frp/gadgets/gadgets.factor @@ -76,6 +76,4 @@ INSTANCE: gadget-monad monad INSTANCE: gadget monad M: gadget monad-of drop gadget-monad ; M: gadget-monad return drop swap >>model ; -M: gadget >>= output-model [ swap call( x -- y ) ] curry ; - -! Make sure prop removal really destroys normal db code \ No newline at end of file +M: gadget >>= output-model [ swap call( x -- y ) ] curry ; \ No newline at end of file