Preheat the oven to 180°C (fan 160°C)/350°F (fan 320°F)/gas mark 4 (fan gas mark 3) and lightly grease a medium-sized baking dish with oil.
Put 2 tablespoons of the oil into a large pan with a lid and place over a medium-high heat. Add the onion and cook gently for 8–10 minutes until softened. Add the garlic, tomatoes, tomato purée, olives, herbs, vinegar, a teaspoon of salt and a quarter of a teaspoon of pepper, then bring to a gentle simmer. Cover with a lid and cook over a low heat for 30 minutes, stirring now and again, until slightly reduced. Taste and adjust the seasoning if necessary.
Meanwhile, place the flour in a wide shallow bowl and season generously with salt and pepper. Coat each slice of aubergine in the seasoned flour and set aside. Put another 2 tablespoons of the olive
oil into a large non-stick frying pan and place over a medium-high heat. Working in batches, so as not to overcrowd the pan, fry the floured aubergine slices for 3–4 minutes on each side until golden. Continue until all are fried, adding more oil as needed.
Cover the base of the greased baking dish with a thin layer of the tomato sauce, then add a layer of aubergine and continue layering until you have used up all of the ingredients. Mix the grated mozzarella with the pine nuts and scatter over the top of the dish. Season with a little more salt and pepper and bake for 30–40 minutes until the top is golden brown and bubbling. Serve immediately.