Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Theme #223

Open
dvdcut opened this issue Apr 27, 2020 · 32 comments
Open

Multiple Theme #223

dvdcut opened this issue Apr 27, 2020 · 32 comments

Comments

@dvdcut
Copy link
Contributor

dvdcut commented Apr 27, 2020

i been thinking about Multiple Theme long time, can we have option to have multiple theme? i think it will only need css modification, anyone else thinking about this? or i have lost my mind :D

@pihome-shc
Copy link
Owner

@dvdcut it is going to he hell of job to do all css. first you need to take out all css code from exiting css files, and then save it in one file to call it default theme, and then each theme would have its of css file. i dont know any other way of doing this may be your or someone else have better idea, but i dont mind having option to alternate theme.

@sandreialexandru
Copy link
Contributor

How about creating another folder called "themes" witch would contain sub-folders with the css files? The folders tree would look like "/themes/theme_name/css/". A php script could copy (overwrite) the css folder into the destination folder. Every theme path first gets inserted into database and $src gets value from there. The GUI would have a dropdownlist with all the themes.
Not a php expert but maybe something like:

<?php
$src = "/var/www/themes/dark/css";
$dest = "/var/www/css";

//version 1
shell_exec("cp -r $src $dest");

//verson 2
copy($src,$dest)
?>

@sandreialexandru
Copy link
Contributor

And maybe add this to the php code so there wouldn't be problems with browser cache

header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

@dvdcut
Copy link
Contributor Author

dvdcut commented May 7, 2020

creating folder is the right way to do this, but i think copying css file for selected theme doesn't sound right, what all these theme sellers do? there must be better way doing this.

@sandreialexandru
Copy link
Contributor

I believe that multiple theme changing modes exist, but they must be implemented. I believe that overwiting files is the simplest way to go, rather than changing the base theme(file paths) in order to add more themes.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 7, 2020

i was googling around and here is one from stackoverflow
Comparison of web template engines
not sure if we can use this or not, but first task would be to extract all the relevent CSS and dump into one basic css file and from there one if any one want to chagne they can feel free.

if we have css only we can simply use following code can do:

if($user_theme_selected == 'basic')
{
      echo '<link href="/css/theme-basic.css" type="text/css" rel="stylesheet"></link>';
}
else if($user_theme_selected == 'premium')
{
      echo '<link href="/css/theme-premium.css" type="text/css" rel="stylesheet"></link>';
}
else
{
      echo '<link href="/css/theme-default.css" type="text/css" rel="stylesheet"></link>';
}

@pihome-shc
Copy link
Owner

i think first extracting css from exiting css is the way to start this, once we have that anyone can have their own style and we can start modifying or each one can modify the theme as you please and if you want to include in PiHome you are welcome.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 8, 2020

@sandreialexandru you want to to work with me on this one? we can work on this to extract all the css code from all css files, what you say?

@sandreialexandru
Copy link
Contributor

Please let me try something this weekend. I have an idea about how I can merge css files.

@sandreialexandru
Copy link
Contributor

Searched for all the css files that are used for GUI and only 2 files need to be modified index.php and header.php .
I have merged all css files into a single one named style.css , which has the path thme/base/style.css

I'm sorry that i cannot test this right now, as i am not home and i haven't got a RaspberryPI nearby.
If someone can test and if it is ok, i can make a pull request.

test.zip

@pihome-shc
Copy link
Owner

@sandreialexandru
just tried your css, and its all blue, looks like lots of code is missing.
image

@sandreialexandru
Copy link
Contributor

I guess it is not as simple as i thought or maybe i have missed something. I'll keep working on this, maybe with the help of @dvdcut .

@pihome-shc
Copy link
Owner

pihome-shc commented May 9, 2020 via email

@dvdcut
Copy link
Contributor Author

dvdcut commented May 12, 2020

@sandreialexandru i m in, let me know what you want me to do,

@sandreialexandru
Copy link
Contributor

I'm guessing that I might have missed something while merging the *.css files found in css folder and sub-folders. Maybe it needs to be re-merged.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 12, 2020

my plan was to extract css code line by line, i know it wasn't easy but i dont say any other way,
we can leave fonts related code as it like font-awesome-4.7.0, glyphicons, ionicons-2.0.1
All CSS files

	<!-- Bootstrap Core CSS -->
	<link href="css/bootstrap.min.css" rel="stylesheet">
	
	<link href="css/animate.css" rel="stylesheet">
	
	<!-- MetisMenu CSS -->
	<link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">
	
	<!-- DataTables CSS -->
	<link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">
	
	<!-- extra line added later for responsive test -->
	<link href="css/plugins/dataTables.responsive.css" rel="stylesheet">
	
	<!-- animate CSS -->
	<link href="css/plugins/animate/animate.css" rel="stylesheet">
	
	<!-- Custom CSS -->
	<link href="css/sb-admin-2.css" rel="stylesheet">
	
	<!-- Datetimepicker CSS -->
	<link href="css/plugins/datepicker/bootstrap-datetimepicker.css" rel="stylesheet">
	
	<!-- Custom Fonts awesome-->
	<link href="fonts/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
	
	<!-- Custom Fonts ionicons-->
	<link rel="stylesheet" type="text/css" media="screen" href="fonts/ionicons-2.0.1/css/ionicons.min.css">

We should focust on following:

	<!-- Bootstrap Core CSS -->
	<link href="css/bootstrap.min.css" rel="stylesheet">
	
	<!-- MetisMenu CSS -->
	<link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">

	<!-- Custom CSS -->
	<link href="css/sb-admin-2.css" rel="stylesheet">
	
	<!-- Datetimepicker CSS -->
	<link href="css/plugins/datepicker/bootstrap-datetimepicker.css" rel="stylesheet">
	

@dvdcut
Copy link
Contributor Author

dvdcut commented May 12, 2020

@pihome-shc
Copy link
Owner

following two would be more important some items in bootstrap.min.css gets overwritten in sb-admin-2.css. may be there is way automatically combine this but so far i can not see anything and google failed to bring anything useful. may be it is manual work.

<!-- Bootstrap Core CSS -->
	<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
	<link href="css/sb-admin-2.css" rel="stylesheet">

@sandreialexandru
Copy link
Contributor

@dvdcut tools look good, but they are used to minify the resulted css file.
@pihome-shc you are right, manual work needs to be done.
I have tried another simple merging but GUI is broken again.

@pihome-shc
Copy link
Owner

@sandreialexandru lets start extracting code item by item, i know it is not going to be simple task.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 22, 2020

this is more difficult then i thought, but even after extracting all css we still need to somehow manage switch between theme, for example if you have Homebridge installed and you can switch between theme right there and i think it is done through ajax. i m going to extract css in next few days and i'll share what i have don, may be someone with better knowledge of ajax can help us on this.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 26, 2020

here is extracted file, but I also realise most of the custom code is in sb-admin-2.css, and we don't need to extract everything, may be few parts need to be brought in from bootstrap.min.css.
@sandreialexandru can you test this?

default.zip

@sandreialexandru
Copy link
Contributor

Yes, I can. I will test your version and give you my feedback. I have been working on an "extraction" myself.

@sandreialexandru
Copy link
Contributor

@dvdcut I'm sorry but your version does not work
This is how it looks:
pihome

I'm trying to browse through the site and use the "inspector" to select all the used css code, but it is a lot to do. I have to be careful at repeating elements.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 27, 2020

i left all the other css in place and added mine at the end.

@dvdcut
Copy link
Contributor Author

dvdcut commented May 29, 2020

@sandreialexandru i did the same thing, but i also noticed that most of the customization is in sb-admin-2.css

@dvdcut
Copy link
Contributor Author

dvdcut commented Jun 6, 2020

@sandreialexandru, did you made any progress? do you need any hlep?

@sandreialexandru
Copy link
Contributor

I've managed to get to the point where I cannot merge boostrap.min.css. I have done some testing and untill now, it is working with only two css files (excluding fonts and icons css). The web interface is a bit faster and I did not find any broken elements. Please help with some testing.

Replace bootstrap.min.css and copy pihome_css.css into /var/www/css
Edit header.php . Replace

<!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
	
	<link href="css/animate.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">
	    <!-- DataTables CSS -->
    <link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">
	<!-- extra line added later for responsive test -->
	<link href="css/plugins/dataTables.responsive.css" rel="stylesheet">
	<!-- animate CSS -->
	<link href="css/plugins/animate/animate.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/sb-admin-2.css" rel="stylesheet">

	<!-- Datetimepicker CSS -->
	<link href="css/plugins/datepicker/bootstrap-datetimepicker.css" rel="stylesheet">

with

<!-- Bootstrap Core CSS -->
   <link href="css/bootstrap.min.css" rel="stylesheet">
 
   <link href="css/pihome_css.css" rel="stylesheet">

css.zip

@pihome-shc
Copy link
Owner

@sandreialexandru
i will test this later and report back the update.

@dvdcut
Copy link
Contributor Author

dvdcut commented Nov 10, 2020

@sandreialexandru i tested your css files and i have no issues so far, now its time to customize some items to see how easy it would be.

@pihome-shc
Copy link
Owner

i can confirm your css.zip file is working great,

@dvdcut
Copy link
Contributor Author

dvdcut commented Nov 18, 2020

can we make this official update then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants