summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-03-24view: Add editing of existing recipe stepsxengineering
2024-03-24view: Add steps to recipe pagexengineering
2024-03-24model: Add recipe stepsxengineering
This provides the infrastructure to create views and HTTP handlers to provide recipe steps.
2024-03-24model: Crash on failed test recipe injectionxengineering
This error used to be silent. Since it is just about test recipes and thus a debugging environment it is best to directly give up and log the error.
2024-03-24view: Fix position of header tagxengineering
It should be inside the body tag but used to be before it.
2024-03-23view: Do not change button colorxengineering
Design changes should be avoided for now since simple.css cares about the CSS part of Ceres.
2024-03-12model: Remove .Touch() methodxengineering
The model package should never modify the data. Thus the functionality to update timestamps is moved to the controller package which is intended to modify data.
2024-03-10view: Remove nested anchor and button elementsxengineering
There is the need to add buttons to the recipe server which act like a anchor tag (link). This can be achieved by nesting anchor and button tag. The problem is that if the user cycles through the elements of the page with the 'tab' key such a button is handled as two overlapping elements instead of one. This commit solves the issue by using buttons with the attribute `onclick="window.location.href='<url>';`.
2024-03-06view: Rework /recipe page layoutxengineering
2024-03-06view: Display multiline notes correctlyxengineering
2024-03-06view: Use textarea for recipe notesxengineering
They are intended to use multiple lines. This is easier to edit in a textarea element rather than in an input element.
2024-03-06view: Display message in case of no recipesxengineering
2024-03-06view: Make recipe portions, URL and notes optionalxengineering
An empty string for one of these attributes will lead to a recipe view page which does not render the paragraph for this item.
2024-03-05model: Move timestamp updates to controllerxengineering
The model package should handle the object relational mapping (ORM). This requires implementing the four CRUD methods: - create - read - update - delete On create and update the model package used to modify the timestamps like `last_changed`. This was detected by the unit tests which tested that the data is not changed in a create / read cycle or is updated correctly in an update / read cycle. This raised the question if it is a good idea that the model package is "smart" and updates timestamps. To keep the model package and the included unit tests simple the new design enforces that the complete data - including metadata - is always exactly the same after using any CRUD methods. The functionality of updating the timestamp is moved to the HTTP handler inside the controller package. This also matches the definition of the controller package as the part of the code which is alone responsible to actually change the data. This commit finally fixes the unit test suite.
2024-03-04model: Implement Stringer interface for Recipexengineering
This allows to print a recipe with a fmt.Printf() call more easily: fmt.Printf("%s\n", recipe) This is also used for better error output in unit tests with t.Fatalf(). The Stringer interface is implemented with the JSON package because an indented version of a recipe is a useful string representation.
2024-03-04model: Create test data with Go instead of SQLxengineering
This allows to formulate the test data with an object-based model which is easier than writing it down in a relational model.
2024-03-03view: Move recipe adding to /recipesxengineering
In the long term the <nav> section at the top should reference the list views of all managed objects (recipes, users, products and so on). With this structure it makes more sense to have the button to add a recipe on the list view on recipes located at /recipes.
2024-03-03view: Add recipe createxengineering
2024-03-03view: Move all JavaScript code to ceres.jsxengineering
This allows to cache the involved JavaScript code.
2024-03-03view: Add template 'nav'xengineering
The <nav> section is the same on every page. This new template reduces code duplication.
2024-03-03controller: Provide recipe create via HTTPxengineering
2024-03-03Add ID to URL in recipe updatesxengineering
This makes the update URL more consistent with the other ones. A check ensures consistency of the URL and JSON ID values.
2024-03-03view: Provide recipe deletionxengineering
2024-03-03view: Add 'Read' suffix to function namesxengineering
This reflects that these HTTP handler functions implement one of the four CRUD methods create, read update and delete.
2024-03-03view: Replace edit by view parameterxengineering
The old edit URL parameter allowed to select one different HTML template. A more generic approach is to provide a view parameter which allows to use multiple alternative HTML templates for the same data defined by the Go struct. This makes implementing additional pages like a confirm page for recipe deletion easier.
2024-03-03view: Provide JS function to delete a recipexengineering
2024-03-03controller: Provide recipe deletion via HTTPxengineering
2024-03-03view: Send forms as JSON with JavaScriptxengineering
While forms can be send without JavaScript this new approach has the benefit that the whole data is send as one JSON. This JSON format can also be used for an API or testing.
2024-03-03controller: Update recipe based on JSONxengineering
2024-03-03model: Assert one affected row on .Update()xengineering
A missing or wrong .Id field for example otherwise results in a silent error because nothing is actually updated.
2024-03-03model: Use only string types for modelsxengineering
When a HTML form is converted to JSON by JavaScript using `FormData()`, `Object.fromEntries()` and `JSON.stringify` the data type is always `string`. This does not match the Go struct definitions using multiple types including e.g. `int`. There are several options to solve this conflict: 1. use only strings in Go struct definitions 2. write custom functions to parse string-based JSONs to Go structs 3. implement custom functions in JS to use `number` type if possible Option 3 seems to be a very clean solution. Nevertheless it is limited by the fact that JSON anyway has a way more limited type system than Go. So the types used in Go cannot be used and this would reduce this option to a variant of option 2. Option 2 requires significant effort per struct inside the model package. Every object which is transferred via JSON and serialized into Go structs would require a second struct definition with string types and a conversion function. This does not scale. Thus option 1 seems to be the best fit. The reasons for using types like `int` or `bool` are: - less memory consumption than `string` in most cases - implicit data validation (e.g. enforcing positive numbers with `uint`) - better compatibility with certain APIs which rely on e.g. `int` The first argument is not so relevant in this use case. The amount of required memory is still quite small for servers. Implicit data validation is a good thing but not enough. There should anyway be validation method which has to be called on CRUD methods and JSON deserialization.
2024-02-15Update github.com/mattn/go-sqlite3 to v1.14.22xengineering
2024-02-15view: Add HTTP 204 handler for /favicon.icoxengineering
Otherwise e.g. the Firefox browser throws an error on the console.
2024-02-15view: Add doctype to HTMLxengineering
2024-02-15view: Reference /recipes with home buttonxengineering
The index page / provides a redirect to /recipes but this is inefficient since two HTTP requests are required.
2024-02-15view: Add index handlerxengineering
2024-02-15view: Add edit view for model.Recipe typexengineering
2024-02-13view: Implement GET handler for model.Recipexengineering
2024-02-13view: Implement GET handler for model.Recipesxengineering
2024-02-11model: Add type 'Recipes' with Read() methodxengineering
This type is provided to render overview pages easily with a list of all recipes.
2024-02-11model: Implement CRUD methods for type Recipexengineering
The new Go type 'Recipe' should contain every information directly related to a recipe. It should be sufficient to pass it to a template to directly render a HTML view or edit page for the recipe or to a template to generate a PDF. The CRUD methods are: - func (r *Recipe) Create() error - func (r *Recipe) Update() error - func (r *Recipe) Read() error - func (r *Recipe) Delete() error Together with the type itself they are the interface the model package provides for recipes.
2024-02-11model: Switch to very basic database schemaxengineering
This simple model is used to test if it is helpful to implement the four CRUD methods create, read, update and delete all inside the model package. The model package should also provide the datastructures for these operations (well suited for the required views) aswell as tests for them. With this approach it should be possible to easily implement the view and controller package because most of the logic is already inside the model package and is tested.
2023-12-27Provide CSS via HTTP serverxengineering
This is a simple first HTTP handler and is required to display the website with the intended design.
2023-12-27Add simple.css submodulexengineering
This CSS framework uses nearly only the standard HTML tags and is thus easy to adopt / replace.
2023-12-27Add HTTP server without handlersxengineering
This adds the infrastructure to add HTTP handlers. It already sets up the HTTP server and makes sure it is started and stopped.
2023-12-27Add github.com/gorilla/muxxengineering
This dependency provides a more extended HTTP routing than the Go standard library.
2023-12-27Shutdown only on OS signalxengineering
This is the intended behaviour for production and also for debugging to at least inspect the data directory of Ceres.
2023-12-27model: Inject test data into databasexengineering
This is useful for debugging and testing.
2023-12-27model: Add initial SQL migrationxengineering
This provides the basic table structure to the database.
2023-12-27model: Implement database connectionxengineering
The already implemented storage folder should contain a sqlite database to store most parts of the Ceres user data.